Merge branch 'feat/cli-account' into feat/feishu-plugin

This commit is contained in:
gengruilin committed 2026-10-29 19:10:23 +08:00
commit e722f2909c
48 files changed
+847 -323

No files matched your search

-1
View File
@@ -38,7 +38,6 @@
"@deepseek-ai/dsh-client-test-runtime": "workspace:*",
"@deepseek-ai/dsh-client-ui-deliverables": "workspace:*",
"@deepseek-ai/dsh-client-ui-dockkit": "workspace:*",
"@deepseek-ai/dsh-client-ui-cli-account": "workspace:*",
"@deepseek-ai/dsh-client-ui-primitives": "workspace:*",
"@deepseek-ai/dsh-client-ui-slots": "workspace:*",
"@deepseek-ai/dsh-client-web": "workspace:*",
+1 -1
View File
@@ -4846,6 +4846,7 @@ These load from a `cordis.yml` entry with no `config:` block; they declare no co
| `@deepseek-ai/dsh-client-ui-attachment` | — | [`packages/client/ui-attachment/src/index.ts`](../packages/client/ui-attachment/src/index.ts) |
| `@deepseek-ai/dsh-client-ui-brand-official` | — | [`packages/client/ui-brand-official/src/index.ts`](../packages/client/ui-brand-official/src/index.ts) |
| `@deepseek-ai/dsh-client-ui-chat` | — | [`packages/client/ui-chat/src/index.ts`](../packages/client/ui-chat/src/index.ts) |
| `@deepseek-ai/dsh-client-ui-cli-account` | — | [`packages/client/ui-cli-account/src/index.ts`](../packages/client/ui-cli-account/src/index.ts) |
| `@deepseek-ai/dsh-client-ui-commands` | — | [`packages/client/ui-commands/src/index.ts`](../packages/client/ui-commands/src/index.ts) |
| `@deepseek-ai/dsh-client-ui-context-menu` | — | [`packages/client/ui-context-menu/src/index.ts`](../packages/client/ui-context-menu/src/index.ts) |
| `@deepseek-ai/dsh-client-ui-conversation` | — | [`packages/client/ui-conversation/src/index.ts`](../packages/client/ui-conversation/src/index.ts) |
@@ -4994,7 +4995,6 @@ Imported as libraries by other packages; a `cordis.yml` cannot load them.
| `@deepseek-ai/dsh-cli-account` | — | [`packages/connector/cli-account/src/index.ts`](../packages/connector/cli-account/src/index.ts) |
| `@deepseek-ai/dsh-client-store` | — | [`packages/client/store/src/index.ts`](../packages/client/store/src/index.ts) |
| `@deepseek-ai/dsh-client-test-runtime` | — | [`packages/test-support/client-runtime/src/index.ts`](../packages/test-support/client-runtime/src/index.ts) |
| `@deepseek-ai/dsh-client-ui-cli-account` | — | [`packages/client/ui-cli-account/src/index.ts`](../packages/client/ui-cli-account/src/index.ts) |
| `@deepseek-ai/dsh-client-ui-dockkit` | — | [`packages/client/ui-dockkit/src/index.ts`](../packages/client/ui-dockkit/src/index.ts) |
| `@deepseek-ai/dsh-client-ui-primitives` | — | [`packages/client/ui-primitives/src/index.ts`](../packages/client/ui-primitives/src/index.ts) |
| `@deepseek-ai/dsh-client-ui-slots` | — | [`packages/client/ui-slots/src/index.ts`](../packages/client/ui-slots/src/index.ts) |
+1 -1
View File
@@ -4848,6 +4848,7 @@ export interface Config {
| `@deepseek-ai/dsh-client-ui-attachment` | — | [`packages/client/ui-attachment/src/index.ts`](../packages/client/ui-attachment/src/index.ts) |
| `@deepseek-ai/dsh-client-ui-brand-official` | — | [`packages/client/ui-brand-official/src/index.ts`](../packages/client/ui-brand-official/src/index.ts) |
| `@deepseek-ai/dsh-client-ui-chat` | — | [`packages/client/ui-chat/src/index.ts`](../packages/client/ui-chat/src/index.ts) |
| `@deepseek-ai/dsh-client-ui-cli-account` | — | [`packages/client/ui-cli-account/src/index.ts`](../packages/client/ui-cli-account/src/index.ts) |
| `@deepseek-ai/dsh-client-ui-commands` | — | [`packages/client/ui-commands/src/index.ts`](../packages/client/ui-commands/src/index.ts) |
| `@deepseek-ai/dsh-client-ui-context-menu` | — | [`packages/client/ui-context-menu/src/index.ts`](../packages/client/ui-context-menu/src/index.ts) |
| `@deepseek-ai/dsh-client-ui-conversation` | — | [`packages/client/ui-conversation/src/index.ts`](../packages/client/ui-conversation/src/index.ts) |
@@ -4996,7 +4997,6 @@ export interface Config {
| `@deepseek-ai/dsh-cli-account` | — | [`packages/connector/cli-account/src/index.ts`](../packages/connector/cli-account/src/index.ts) |
| `@deepseek-ai/dsh-client-store` | — | [`packages/client/store/src/index.ts`](../packages/client/store/src/index.ts) |
| `@deepseek-ai/dsh-client-test-runtime` | — | [`packages/test-support/client-runtime/src/index.ts`](../packages/test-support/client-runtime/src/index.ts) |
| `@deepseek-ai/dsh-client-ui-cli-account` | — | [`packages/client/ui-cli-account/src/index.ts`](../packages/client/ui-cli-account/src/index.ts) |
| `@deepseek-ai/dsh-client-ui-dockkit` | — | [`packages/client/ui-dockkit/src/index.ts`](../packages/client/ui-dockkit/src/index.ts) |
| `@deepseek-ai/dsh-client-ui-primitives` | — | [`packages/client/ui-primitives/src/index.ts`](../packages/client/ui-primitives/src/index.ts) |
| `@deepseek-ai/dsh-client-ui-slots` | — | [`packages/client/ui-slots/src/index.ts`](../packages/client/ui-slots/src/index.ts) |
+5
View File
@@ -314,6 +314,11 @@
- id: ui-plugin-manager
name: '@deepseek-ai/dsh-client-ui-plugin-manager'
# Account section, title tag, activation prompt, and notices that CLI app
# plugins register on the Plugins page over their own account Remotes.
- id: ui-cli-account
name: '@deepseek-ai/dsh-client-ui-cli-account'
# Read-only Plugin list tab in the Settings Plugins section; the built-in
# bundles the sidebar page leaves out are inspected here.
- id: ui-settings-plugin-inventory
+1
View File
@@ -78,6 +78,7 @@
"@deepseek-ai/dsh-client-ui-brand-official": "workspace:*",
"@deepseek-ai/dsh-message-quotes": "workspace:*",
"@deepseek-ai/dsh-client-ui-chat": "workspace:*",
"@deepseek-ai/dsh-client-ui-cli-account": "workspace:*",
"@deepseek-ai/dsh-client-ui-commands": "workspace:*",
"@deepseek-ai/dsh-client-ui-conversation": "workspace:*",
"@deepseek-ai/dsh-client-ui-cordis": "workspace:*",
+2 -2
View File
@@ -15,8 +15,8 @@
en: 1eb35b015a6c423f
zh: a8a3dceee2c9e943
/client-web-gui-browser-half/packages:
en: 28c79824490862f2
zh: 1103845879f2dbbb
en: 45f2781bd178f00a
zh: ed9c01b1be743b63
/client-web-gui-browser-half/related-documentation:
en: d1d506e68fab7333
zh: 1a90fe6f3f8f24a9
+1 -1
View File
@@ -81,7 +81,7 @@ The kernel packages boot and serve the page; the UI feature packages present it.
| [`ui-settings-session-log/`](ui-settings-session-log/README.md) | Controls API Session-log upload in General settings | — |
| [`ui-settings-subagent/`](ui-settings-subagent/README.md) | Provides the Subagent settings page on the Plugins page | — |
| [`ui-settings-web-search/`](ui-settings-web-search/README.md) | Provides the web-search settings page on the Plugins page | — |
| [`ui-cli-account/`](ui-cli-account/README.md) | Shares the account section, tag, activation prompt, confirmations, and notices that CLI app plugins show on the Plugins page | — |
| [`ui-cli-account/`](ui-cli-account/README.md) | Shows the account section, tag, activation prompt, confirmations, and notices that CLI app plugins register on the Plugins page | `ctx.cliAccounts` |
| [`ui-plugin-manager/`](ui-plugin-manager/README.md) | Contributes the sidebar Plugins panel: install, enable, disable, retry, and compose installed packages | — |
| [`ui-entry-customization/`](ui-entry-customization/README.md) | Adds region-local More menus that pin or unpin plugin launchers and start a plugin draft | — |
| [`ui-plugin-market/`](ui-plugin-market/README.md) | Contributes the Discover tab to the Plugins page: browse market indexes and install their bundles | — |
+1 -1
View File
@@ -81,7 +81,7 @@ kind: "package-group"
| [`ui-settings-session-log/`](ui-settings-session-log/README.zh.md) | 在通用设置中控制随 API 上传会话日志 | — |
| [`ui-settings-subagent/`](ui-settings-subagent/README.zh.md) | 在插件页提供子智能体设置页 | — |
| [`ui-settings-web-search/`](ui-settings-web-search/README.zh.md) | 在插件页提供网页搜索设置页 | — |
| [`ui-cli-account/`](ui-cli-account/README.zh.md) | 提供 CLI 应用插件在插件页共用的账号区块、标签、开启引导、确认和提示 | — |
| [`ui-cli-account/`](ui-cli-account/README.zh.md) | 显示 CLI 应用插件在插件页注册的账号区块、标签、开启引导、确认和提示 | `ctx.cliAccounts` |
| [`ui-plugin-manager/`](ui-plugin-manager/README.zh.md) | 贡献侧栏的“插件”面板:安装、启用、停用、重试与组合已安装的包 | — |
| [`ui-entry-customization/`](ui-entry-customization/README.zh.md) | 添加分区域的“更多”菜单,固定或收起插件入口,并开始创建插件的草稿 | — |
| [`ui-plugin-market/`](ui-plugin-market/README.zh.md) | 为“插件”页面贡献“发现”标签页:浏览市场索引并安装其中的组合包 | — |
+29 -29
View File
@@ -3,50 +3,50 @@
# After editing either side, bring the other along and re-record with:
# pnpm run verify-translation-pairing --write packages/client/ui-cli-account/README.md
/:
en: e49d68d248f36cad
zh: 3ec31254dd83e58b
en: 2a9fe27e72f4a975
zh: 969761d0befd982e
/deepseek-ai-dsh-client-ui-cli-account:
en: 9459a591a9b82dd8
zh: cb4059b1ef791c5c
/deepseek-ai-dsh-client-ui-cli-account/summary:
en: 543480ffecd1db84
zh: c6c564bd3830b1e8
en: cb14be46b7eb347e
zh: 2f4478ad48ea8fd2
/deepseek-ai-dsh-client-ui-cli-account/table-of-contents:
en: d152484eb41ac6b4
zh: 5b6bd00fce5371c3
/deepseek-ai-dsh-client-ui-cli-account/use-this-package:
en: 833ecd065f2d155a
zh: 347c28933ce652b6
en: 82bc46a60479254c
zh: 8b0ea3415ab8a35b
/deepseek-ai-dsh-client-ui-cli-account/use-this-package/when-to-choose-it:
en: c63cdee18f15d294
zh: ce6105e42a08add5
/deepseek-ai-dsh-client-ui-cli-account/use-this-package/import-it:
en: 11de80ae029060b6
zh: 1a015a9f08a6c077
/deepseek-ai-dsh-client-ui-cli-account/use-this-package/connection-mirror:
en: 6af5224197752d85
zh: ee237ea0c6b5096f
/deepseek-ai-dsh-client-ui-cli-account/use-this-package/register-an-account:
en: 14d247f65f5a3dfa
zh: 7300c38f179e5ee1
/deepseek-ai-dsh-client-ui-cli-account/use-this-package/present-the-section:
en: faab698b3dd76448
zh: 85d24414e05606f5
/deepseek-ai-dsh-client-ui-cli-account/use-this-package/following-operations:
en: 2c9eb9885c50592e
zh: bc7619a5173f161b
/deepseek-ai-dsh-client-ui-cli-account/use-this-package/shared-dictionary-keys:
en: 150d9df6824f2636
zh: 9b6d68043b1bb730
/deepseek-ai-dsh-client-ui-cli-account/use-this-package/components:
en: 2ef238529bb61294
zh: ede59a7b5e75b44d
en: f9a8b0974afb8bf9
zh: 334b9d8fc711aec1
/deepseek-ai-dsh-client-ui-cli-account/understand-the-implementation:
en: 49b07dcf9d1d9810
zh: d6100e7aba70a06c
en: 5ec779496ac5f7dd
zh: ec3938ad0a9656d9
/deepseek-ai-dsh-client-ui-cli-account/further-exploration:
en: 3a734faf91117774
zh: ec057434b2d19223
en: 368d56aaef042324
zh: 00314c6285c0beb9
/deepseek-ai-dsh-client-ui-cli-account/model-experience:
en: 525d8f762d62abcd
zh: dfdbba035632096a
en: 47f94c48dcc93bae
zh: 9584dee7c543c6c7
/deepseek-ai-dsh-client-ui-cli-account/model-experience/kv-cache-effect:
en: ca75c51c89c2c9b0
zh: 6e1c9a8fdde89577
en: 4cd0965a7997970e
zh: 81b3b87b2ba4756f
/deepseek-ai-dsh-client-ui-cli-account/known-limitations-and-deferred-work:
en: 3ef957892d693131
zh: 81e65fee74a7ef0b
en: bb83d0b097834b84
zh: c39b0869c99aa9eb
/deepseek-ai-dsh-client-ui-cli-account/known-limitations-and-deferred-work/dev-note:
en: e67f633dc6fe7773
zh: e88aeb617ffb74ea
en: 00853dccb6e5f32c
zh: 8b082da910fc429a
+51 -29
View File
@@ -1,6 +1,6 @@
---
description: "Give a CLI app plugin's Plugins page its account section, title tag, activation prompt, confirmations, and notices, mirrored from the plugin's Host account Remote with copy the plugin translates."
kind: "package-library"
description: "Show a CLI app plugin's account section, title tag, activation prompt, confirmations, and notices on the Plugins page through `ctx.cliAccounts`, following the plugin's Host account Remote with copy the plugin translates."
kind: "package-reference"
---
# @deepseek-ai/dsh-client-ui-cli-account
@@ -9,7 +9,7 @@ English | [中文](README.zh.md)
## Summary
CLI app plugins such as Feishu and WeCom build their Plugins page from these shared pieces. `CliAccountConnection` follows the plugin's account stream, opens an authorization link once in the browser that started the operation, and reports outcomes. The section, tag, activation prompt, confirmation, and notice components render one of six display phases with copy the plugin translates. The Web shell links this library statically and shares one copy through its module table, so plugins import it like `ui-primitives`. Each plugin keeps its own presentation and dictionary.
CLI app plugins such as Feishu and WeCom show their account on the Plugins page by registering it with `ctx.cliAccounts`. The registry follows the plugin's account stream, opens an authorization link once in the browser that started the operation, and renders the section, title tag, activation prompt, confirmations, and notices. Each plugin keeps its own Remote operations, presentation, and dictionary. The Web and Desktop compositions mount the registry through [`dsh-web-app`](../../bundle/web-app/README.md).
## Table of Contents
@@ -25,33 +25,53 @@ CLI app plugins such as Feishu and WeCom build their Plugins page from these sha
<a id="use-this-package"></a>
## Use this package
A plugin page imports this library, creates one connection over its Remote, maps the Host view to a display phase, and renders the shared components.
A plugin's browser half registers its account once, with its Remote operations, its dictionary, and a presenter that maps the page snapshot to what the section shows.
### When to choose it
Choose it for the page half of a plugin built on [`@deepseek-ai/dsh-cli-account`](../../connector/cli-account/README.md), whose Remote streams a `CliAccountView`. A plugin that connects a hosted service over MCP uses the MCP account surfaces instead.
### Import it
### Register an account
A plugin page imports `@deepseek-ai/dsh-client-ui-cli-account` and lists it in its `devDependencies`. The package is one of the Web shell's `PLATFORM_MODULES`, so a plugin bundle resolves the import against the shell's copy without `dsh.client.external`, and the client bundle purity gate rejects a bundle that inlines it instead. This package is a Web-shell build input: its static ESM keeps its CSS module for Vite, and it has no Loader row or configuration fields.
The plugin's browser half injects `locale` and `cliAccounts`, registers its dictionary, and registers its account for its own lifetime:
### Connection mirror
```ts ignore-check
export const inject = ['remote', 'locale', 'cliAccounts']
`new CliAccountConnection(ctx, { name, follow, cancel, notices })` opens the plugin's `follow` stream through `ctx.remote.$stream` and publishes a snapshot with the Host view, whether the stream is delivering or has stopped, whether a page action is pending, and the latest notice. `start(call)` runs one Remote start at a time and ignores clicks while one is pending; a rejected start or cancel reports the `action-failed` notice once. The page follows the operation its latest start returned, from that answer until the stream delivers the operation's result; each start attempt first drops the operation followed before, so a rejected start leaves none. Each link the followed operation offers opens once in a new window, over HTTPS only, and a later operation that offers the same link opens it again. When the followed operation succeeds, the page reports the notice `notices` maps its kind to; a result that a later operation replaces before the stream delivers it reports nothing. A stream that fails for good marks the snapshot stopped, and `retry()` reopens it once, however often it is called. `dispose()` closes the stream; afterwards the connection opens no link, reports no notice, and opens no stream for a pending retry, while Host-owned operations keep running. `actions` binds `cancel`, `openAuthorization`, `retry`, and `dismissNotice` for a plugin's face.
export function apply(ctx: Context): void {
ctx.effect(() => ctx.locale.register(NS, { zh, en }), 'acme: dictionaries')
const t = ctx.locale.bind(NS)
ctx.effect(() => ctx.cliAccounts.register({
packageName: '@acme/cli', locale: NS,
follow: signal => ctx.remote.acme.follow(signal),
cancel: id => ctx.remote.acme.cancel(id),
notices: { connect: () => t('notice.connected') },
present: (snapshot, page) => presentAccount(snapshot, page, t),
}), 'acme: account')
}
```
`packageName` is the npm package whose bundle page carries the section and tag. `locale` names the plugin's dictionary namespace, which must translate every [shared key](#shared-dictionary-keys); TypeScript rejects a namespace that lacks one. `follow` and `cancel` call the plugin's Remote. `notices` maps an operation kind to the translated notice its success reports in the browser that started it; unlisted kinds report none. The plugin lists `@deepseek-ai/dsh-client-ui-cli-account` in `dsh.client.inject` and imports its types with `import type`. The returned disposer removes the surfaces and closes the account's Host stream. A registration whose package is already registered throws and leaves none of its surfaces behind.
### Present the section
`present(snapshot, page)` runs while a surface renders and returns a `CliAccountDisplay`: the phase, an optional status label, buttons, detail, extra rows, and failure, with every string translated. It reads only the snapshot, so translating through `ctx.locale.bind` follows a language switch. Button callbacks use `page`: `start(call)` runs one Remote start at a time, and `cancel`, `openAuthorization`, and `retry` act on the followed operation and the Host stream. The snapshot carries the Host view, whether the stream is delivering or has stopped, whether a page action is pending, and the latest notice.
| Surface | Behavior |
|---|---|
| Section | Title, status, buttons, detail, extra rows, failure, and hint; the status defaults to the phase's `status.*` copy, with `connecting` labelled as checking. Buttons are disabled while a page action is pending or the Host stream is down, except while stopped so retry can reopen it. A button with `confirm` asks first and runs only after the user accepts. A failure shows the plugin's guidance, then the classified command, exit code, and allowlisted details |
| Title tag | Shown only on the enabled bundle's page or one of its row pages, and only once the phase settles |
| Activation prompt | Open while the phase is `disconnected` after the bundle is switched on; Connect opens the bundle page and runs the section's first primary button that asks no confirmation. It dismisses itself once the phase settles elsewhere |
| Notice | The latest outcome, outside the Plugins panel's lifetime: the plugin's success copy, or the shared failure copy with a warning icon |
### Following operations
The page follows the operation its latest start returned, from that answer until the stream delivers the operation's result; each start attempt first drops the operation followed before, so a rejected start leaves none and reports the `action-failed` notice once. Clicks while a page action is pending are ignored. Each link the followed operation offers opens once in a new window, over HTTPS only, and a later operation that offers the same link opens it again. A result that a later operation replaces before the stream delivers it reports nothing. A stream that fails for good marks the snapshot stopped, and `retry` reopens it once, however often it is called. Removing the registration closes the stream; afterwards the page opens no link and reports no notice, while Host-owned operations keep running.
<a id="shared-dictionary-keys"></a>
### Shared dictionary keys
The components read these keys through the plugin's translator, so every plugin dictionary defines them and TypeScript rejects one that omits a key: `section.title`, `hint`, `close`, `action.cancel`, `action.connect`, `activation.title`, `activation.body`, `activation.later`, `failure.details` (with `{details}`), `failure.exitCode` (with `{code}`), `badge.<phase>` for every phase but `checking`, and `status.<phase>` for every phase but `connecting`. The notice also reads `notice.<kind>` for each kind the plugin maps and for `action-failed`.
### Components
| Component | Behavior |
|---|---|
| `CliAccountSection` | Title, status, buttons, detail, extra rows, failure, and hint; the status defaults to the phase's `status.*` copy. Buttons are disabled while a page action is pending or the Host stream is down, except while stopped so retry can reopen it. A failure shows the plugin's guidance, then the classified command, exit code, and allowlisted details |
| `CliAccountBadge` | The tag beside the title, only on the enabled bundle's page or one of its row pages, and only once the phase settles |
| `CliAccountActivation` | The prompt after the bundle is switched on, open while disconnected; it dismisses itself once the phase settles elsewhere |
| `CliAccountConfirm` | A confirmation that closes before it confirms |
| `CliAccountToast` | The latest notice, with a warning icon for `action-failed` |
The surfaces read these keys from the plugin's namespace: `section.title`, `hint`, `close`, `action.cancel`, `action.connect`, `activation.title`, `activation.body`, `activation.later`, `failure.details` (with `{details}`), `failure.exitCode` (with `{code}`), `notice.action-failed`, `badge.<phase>` for every phase but `checking`, and `status.<phase>` for every phase but `connecting`.
-----
@@ -61,13 +81,15 @@ The components read these keys through the plugin's translator, so every plugin
<details>
<summary>Implementation internals — click to expand</summary>
[`src/index.ts`](src/index.ts) exports the mirror and the components and has no plugin entry. The Web shell seeds the package into its module table, so every plugin page shares one copy instead of inlining its own. The components receive translated text and display phases only; deriving the phase from a plugin's account states stays in the plugin.
`register()` creates one `CliAccountConnection` per account. It mirrors the plugin's `follow` stream and keeps the Host view, whether the stream is delivering, whether a page action is pending, and the latest notice. The registration contributes `plugins.bundle.config` and `plugins.bundle.activation` keyed by the package name, a `plugins.detail.badge` entry with id `<package>.account`, and a `shell.overlay` notice with id `<package>.account-toast`. Each entry declares the plugin's namespace, so the renderer supplies its `t`, and all four inject one face that shares one snapshot and calls the plugin's presenter. The registration is one effect of this plugin's fiber: a setup failure disposes what it already added, and teardown removes the slot entries before closing the stream, whichever of the plugin's disposer and this plugin's unload runs first.
| File | Role |
|---|---|
| [`src/connection.ts`](src/connection.ts) | The Host view mirror, link opening, notices, and pending-action guard |
| [`src/components.tsx`](src/components.tsx) | The shared components, display phases, and dictionary keys |
| [`src/index.ts`](src/index.ts) | The library entry the shell's module table serves |
| [`src/client/index.ts`](src/client/index.ts) | The `ctx.cliAccounts` registry and the four slot registrations |
| [`src/client/types.ts`](src/client/types.ts) | Registration, display, snapshot, and dictionary types |
| [`src/client/connection.ts`](src/client/connection.ts) | The Host view mirror, link opening, notices, and pending-action guard |
| [`src/client/components.tsx`](src/client/components.tsx) | The surfaces and the slot entries that read the face |
| [`src/index.ts`](src/index.ts) | The empty Node half |
</details>
@@ -77,19 +99,19 @@ The components read these keys through the plugin's translator, so every plugin
## Further Exploration
- [CLI account library](../../connector/cli-account/README.md) — the Host half that streams the view.
- [Web shell](../web/README.md) — `PLATFORM_MODULES`, the shared module table that supplies this library.
- [Plugin manager page](../ui-plugin-manager/README.md) — the Plugins page and its bundle slots.
- [Client package map](../README.md) — adjacent browser UI packages.
-----
<a id="model-experience"></a>
## Model Experience
None, as the package is a browser-side UI layer that registers nothing model-facing.
None, as the account surfaces are browser UI and add no model input. Each plugin documents the CLI and skills its account enables.
#### KV Cache effect
None; this package neither assembles nor sends a provider request.
None; registering or removing an account changes no model-visible text.
## Known Limitations and Deferred Work
@@ -97,8 +119,8 @@ None; this package neither assembles nor sends a provider request.
- The six display phases are fixed; a plugin maps any further account state onto one of them.
- The shared dictionary keys are the same for every plugin; a plugin cannot rename them.
- The library registers no slots; each plugin registers its own section, tag, activation, and notice entries.
- The Web shell carries the library whether or not a CLI app plugin is installed.
- Each account opens its own Host stream.
- The Web and Desktop compositions load the registry whether or not a CLI app plugin is installed.
<a id="dev-note"></a>
### Dev Note
@@ -106,6 +128,6 @@ None; this package neither assembles nor sends a provider request.
<details>
<summary>Working context for maintainers — click to expand</summary>
None.
Client specs drive `CliAccountConnection` with a fake Remote stream, render the surfaces with a key-echo translator, and register accounts against a real slot registry.
</details>
+51 -29
View File
@@ -1,6 +1,6 @@
---
description: "为 CLI 应用插件的插件页提供账号区块、标题旁标签、开启引导、确认和提示,内容镜像自插件的 Host 账号 Remote,文案由插件翻译。"
kind: "package-library"
description: "通过 `ctx.cliAccounts` 在插件页显示 CLI 应用插件的账号区块、标题旁标签、开启引导、确认和提示,内容跟随插件的 Host 账号 Remote,文案由插件翻译。"
kind: "package-reference"
---
# @deepseek-ai/dsh-client-ui-cli-account
@@ -9,7 +9,7 @@ kind: "package-library"
## 概述
飞书、企业微信等 CLI 应用插件用这些共用组件搭建自己的插件页。`CliAccountConnection` 跟随插件的账号流,在发起操作的浏览器中把授权链接打开一次,并报告结果。区块、标签、开启引导、确认和提示组件按插件翻译的文案,渲染六种显示阶段之一。Web 外壳静态链接这个库,并通过模块表共享同一份,插件像使用 `ui-primitives` 一样导入它。每个插件保留各自的展示推导和字典。
飞书、企业微信等 CLI 应用插件通过 `ctx.cliAccounts` 注册账号,在插件页显示账号。注册表跟随插件的账号流,在发起操作的浏览器中把授权链接打开一次,并渲染区块、标题旁标签、开启引导、确认和提示。每个插件保留各自的 Remote 操作、展示推导和字典。Web 与桌面端组合通过 [`dsh-web-app`](../../bundle/web-app/README.zh.md) 挂载注册表。
## 目录
@@ -25,33 +25,53 @@ kind: "package-library"
<a id="use-this-package"></a>
## 使用此包
插件页导入这个库,基于自己的 Remote 创建一个连接,把 Host 视图映射为显示阶段,再渲染共用组件。
插件的浏览器一半注册一次账号,提供自己的 Remote 操作、字典,以及把页面快照映射为区块内容的展示函数。
### 何时选择
用于基于 [`@deepseek-ai/dsh-cli-account`](../../connector/cli-account/README.zh.md) 的插件的页面一半,其 Remote 流式推送 `CliAccountView`。通过 MCP 接入托管服务的插件改用 MCP 账号界面。
### 导入
### 注册账号
插件页导入 `@deepseek-ai/dsh-client-ui-cli-account`,并把它列入 `devDependencies`。本包是 Web 外壳的 `PLATFORM_MODULES` 之一,因此插件 bundle 无需 `dsh.client.external` 就会把导入解析到外壳的那一份;如果插件 bundle 把它内联进来,客户端 bundle 纯净性检查会拒绝。本包是 Web 外壳的构建输入:其静态 ESM 为 Vite 保留 CSS module,没有 Loader 行,也没有配置字段。
插件的浏览器一半注入 `locale` 和 `cliAccounts`,注册字典,并在自身生命周期内注册账号:
### 连接镜像
```ts ignore-check
export const inject = ['remote', 'locale', 'cliAccounts']
`new CliAccountConnection(ctx, { name, follow, cancel, notices })` 通过 `ctx.remote.$stream` 打开插件的 `follow` 流,并发布快照,包含 Host 视图、流是否在推送或已停止、是否有页面操作未完成,以及最新提示。`start(call)` 一次只运行一个 Remote 启动调用,有调用未完成时忽略点击;启动或取消被拒绝时只报告一次 `action-failed` 提示。页面跟随其最近一次启动调用返回的操作,从调用返回起,直到流送达该操作的结果;每次发起启动都会先放下之前跟随的操作,因此启动被拒绝时不跟随任何操作。被跟随的操作提供的每个链接只在新窗口中打开一次,且只打开 HTTPS 链接;后续操作提供同一链接时会再次打开。被跟随的操作成功时,报告 `notices` 为其类型映射的提示;如果该结果在流送达之前就被后续操作取代,则不报告任何提示。流永久失败时快照标记为已停止,`retry()` 会重新打开一次,无论调用多少次。`dispose()` 关闭流;此后连接不再打开链接、不再报告提示,也不会为未完成的重试打开流,而 Host 持有的操作继续运行。`actions` 为插件的 face 绑定了 `cancel`、`openAuthorization`、`retry` 和 `dismissNotice`。
export function apply(ctx: Context): void {
ctx.effect(() => ctx.locale.register(NS, { zh, en }), 'acme: dictionaries')
const t = ctx.locale.bind(NS)
ctx.effect(() => ctx.cliAccounts.register({
packageName: '@acme/cli', locale: NS,
follow: signal => ctx.remote.acme.follow(signal),
cancel: id => ctx.remote.acme.cancel(id),
notices: { connect: () => t('notice.connected') },
present: (snapshot, page) => presentAccount(snapshot, page, t),
}), 'acme: account')
}
```
`packageName` 是其插件包页面承载区块和标签的 npm 包。`locale` 指定插件的字典命名空间,它必须翻译每个[共用键](#shared-dictionary-keys);缺少任何一个,TypeScript 都会拒绝该命名空间。`follow` 和 `cancel` 调用插件的 Remote。`notices` 把操作类型映射为该操作成功时、在发起它的浏览器中报告的已翻译提示;未列出的类型不报告提示。插件把 `@deepseek-ai/dsh-client-ui-cli-account` 列入 `dsh.client.inject`,并用 `import type` 导入其类型。返回的销毁函数会移除这些界面并关闭该账号的 Host 流。如果注册的包已被注册,调用会抛出异常,且不留下任何界面。
### 展示区块
`present(snapshot, page)` 在界面渲染时运行,返回 `CliAccountDisplay`:阶段、可选的状态文案、按钮、说明、附加行和失败信息,其中所有文案都已翻译。它只读取快照,因此通过 `ctx.locale.bind` 翻译时会跟随语言切换。按钮回调使用 `page`:`start(call)` 一次只运行一个 Remote 启动调用,`cancel`、`openAuthorization` 和 `retry` 作用于被跟随的操作和 Host 流。快照包含 Host 视图、流是否在推送或已停止、是否有页面操作未完成,以及最新提示。
| 界面 | 行为 |
|---|---|
| 区块 | 标题、状态、按钮、说明、附加行、失败和提示;状态默认取该阶段的 `status.*` 文案,`connecting` 显示为检查中。页面操作未完成或 Host 流中断时按钮禁用,但在已停止时保持可用,以便重试重新打开流。带 `confirm` 的按钮会先询问,用户确认后才执行。失败时先显示插件的恢复建议,再显示分类后的命令、退出码和白名单字段 |
| 标题旁标签 | 只在已启用插件包的页面或其某一行的页面上、并且阶段确定后显示 |
| 开启引导 | 开启插件包后,阶段为 `disconnected` 时打开;“连接”会打开插件包页面,并执行区块中第一个不需要确认的主要按钮。阶段确定为其他状态后自行关闭 |
| 提示 | 在插件面板生命周期之外报告最新结果:插件的成功文案,或带警告图标的共用失败文案 |
### 跟随操作
页面跟随其最近一次启动调用返回的操作,从调用返回起,直到流送达该操作的结果;每次发起启动都会先放下之前跟随的操作,因此启动被拒绝时不跟随任何操作,并只报告一次 `action-failed` 提示。有页面操作未完成时,点击会被忽略。被跟随的操作提供的每个链接只在新窗口中打开一次,且只打开 HTTPS 链接;后续操作提供同一链接时会再次打开。如果某个结果在流送达之前就被后续操作取代,则不报告任何提示。流永久失败时快照标记为已停止,`retry` 会重新打开一次,无论调用多少次。移除注册会关闭流;此后页面不再打开链接、不再报告提示,而 Host 持有的操作继续运行。
<a id="shared-dictionary-keys"></a>
### 共用字典键
组件通过插件的翻译函数读取这些键,因此每个插件字典都要定义它们,缺少任何一个都会被 TypeScript 拒绝:`section.title`、`hint`、`close`、`action.cancel`、`action.connect`、`activation.title`、`activation.body`、`activation.later`、`failure.details`(含 `{details}`)、`failure.exitCode`(含 `{code}`)、除 `checking` 外每个阶段的 `badge.<phase>`,以及除 `connecting` 外每个阶段的 `status.<phase>`。提示组件还会读取插件映射的每种提示的 `notice.<kind>`,以及 `action-failed`。
### 组件
| 组件 | 行为 |
|---|---|
| `CliAccountSection` | 标题、状态、按钮、说明、附加行、失败和提示;状态默认取该阶段的 `status.*` 文案。页面操作未完成或 Host 流中断时按钮禁用,但在已停止时保持可用,以便重试重新打开流。失败时先显示插件的恢复建议,再显示分类后的命令、退出码和白名单字段 |
| `CliAccountBadge` | 标题旁的标签,只在已启用插件包的页面或其某一行的页面上、并且阶段确定后显示 |
| `CliAccountActivation` | 开启插件包后的引导,未连接时打开;阶段确定为其他状态后自行关闭 |
| `CliAccountConfirm` | 先关闭再执行确认的确认框 |
| `CliAccountToast` | 最新提示;`action-failed` 带警告图标 |
这些界面从插件的命名空间读取以下键:`section.title`、`hint`、`close`、`action.cancel`、`action.connect`、`activation.title`、`activation.body`、`activation.later`、`failure.details`(含 `{details}`)、`failure.exitCode`(含 `{code}`)、`notice.action-failed`、除 `checking` 外每个阶段的 `badge.<phase>`,以及除 `connecting` 外每个阶段的 `status.<phase>`。
-----
@@ -61,13 +81,15 @@ kind: "package-library"
<details>
<summary>实现内部细节——点击展开</summary>
[`src/index.ts`](src/index.ts) 导出连接镜像和组件,没有插件入口。Web 外壳把本包放进模块表,因此每个插件页共用同一份代码,而不是各自内联一份。组件只接收翻译好的文案和显示阶段;从插件的账号状态推导显示阶段,仍由插件负责。
`register()` 为每个账号创建一个 `CliAccountConnection`。它镜像插件的 `follow` 流,保存 Host 视图、流是否在推送、是否有页面操作未完成,以及最新提示。一次注册会贡献以包名为键的 `plugins.bundle.config` 和 `plugins.bundle.activation`、id 为 `<package>.account` 的 `plugins.detail.badge` 条目,以及 id 为 `<package>.account-toast` 的 `shell.overlay` 提示。每个条目都声明插件的命名空间,因此渲染器会提供它的 `t`;四个条目注入同一个 face,共享同一份快照,并调用插件的展示函数。注册是本插件 fiber 上的一个 effect:初始化失败时会销毁已经添加的部分;无论插件的销毁函数和本插件的卸载哪个先发生,拆除时都会先移除插槽条目,再关闭流。
| 文件 | 职责 |
|---|---|
| [`src/connection.ts`](src/connection.ts) | Host 视图镜像、链接打开、提示与未完成操作保护 |
| [`src/components.tsx`](src/components.tsx) | 共用组件、显示阶段与字典键 |
| [`src/index.ts`](src/index.ts) | 外壳模块表提供的库入口 |
| [`src/client/index.ts`](src/client/index.ts) | `ctx.cliAccounts` 注册表与四个插槽注册 |
| [`src/client/types.ts`](src/client/types.ts) | 注册、展示、快照与字典类型 |
| [`src/client/connection.ts`](src/client/connection.ts) | Host 视图镜像、链接打开、提示与未完成操作保护 |
| [`src/client/components.tsx`](src/client/components.tsx) | 各个界面,以及从 face 读取数据的插槽条目 |
| [`src/index.ts`](src/index.ts) | 空的 Node 一半 |
</details>
@@ -77,19 +99,19 @@ kind: "package-library"
## 延伸阅读
- [CLI 账号库](../../connector/cli-account/README.zh.md)——推送视图的 Host 一半。
- [Web 外壳](../web/README.zh.md)——`PLATFORM_MODULES`,提供本库的共享模块表。
- [插件管理页面](../ui-plugin-manager/README.zh.md)——插件页及其插件包插槽。
- [客户端包索引](../README.zh.md)——相邻的浏览器 UI 包。
-----
<a id="model-experience"></a>
## 模型体验
无,因为本包是浏览器侧 UI 层,不注册任何面向模型的内容。
无,因为账号界面是浏览器 UI,不增加任何模型输入。每个插件各自说明其账号启用的 CLI 和技能。
#### KV 缓存影响
无;本包既不组装也不发送提供方请求。
无;注册或移除账号不会改变任何模型可见文本。
## 已知限制与后续工作
@@ -97,8 +119,8 @@ kind: "package-library"
- 六种显示阶段是固定的;插件要把其他账号状态映射到其中之一。
- 共用字典键对所有插件都相同;插件不能改名。
- 本库不注册插槽;每个插件注册自己的区块、标签、开启引导和提示条目。
- 无论是否安装了 CLI 应用插件,Web 外壳都带着本库。
- 每个账号各自打开一条 Host 流。
- 无论是否安装了 CLI 应用插件,Web 与桌面端组合都会加载注册表。
<a id="dev-note"></a>
### 开发备注
@@ -106,6 +128,6 @@ kind: "package-library"
<details>
<summary>维护者工作上下文——点击展开</summary>
无。
客户端测试用模拟的 Remote 流驱动 `CliAccountConnection`,用回显键名的翻译函数渲染各个界面,并在真实的插槽注册表上注册账号。
</details>
@@ -0,0 +1,6 @@
{
"meta": {
"title": "CLI-Kontoverbindung",
"description": "Kontobereich, Titel-Tag, Aktivierungshinweis und Benachrichtigungen auf der Seite „Plugins“ für CLI-App-Plugins."
}
}
@@ -0,0 +1,6 @@
{
"meta": {
"title": "CLI account connection",
"description": "Account section, title tag, activation prompt, and notices on the Plugins page for CLI app plugins."
}
}
@@ -0,0 +1,6 @@
{
"meta": {
"title": "Conexión de cuenta de CLI",
"description": "Sección de cuenta, etiqueta del título, aviso de activación y notificaciones en la página Complementos para los complementos de aplicaciones CLI."
}
}
@@ -0,0 +1,6 @@
{
"meta": {
"title": "Connexion de compte CLI",
"description": "Section de compte, étiquette de titre, invite d’activation et notifications sur la page Plugins pour les plugins d’applications CLI."
}
}
@@ -0,0 +1,6 @@
{
"meta": {
"title": "CLI アカウント接続",
"description": "CLI アプリプラグイン向けに、「プラグイン」ページでのアカウントセクション、タイトルタグ、有効化時の案内、通知を提供します。"
}
}
@@ -0,0 +1,6 @@
{
"meta": {
"title": "Conexão de conta da CLI",
"description": "Seção da conta, etiqueta do título, aviso de ativação e notificações na página Plug-ins para plugins de aplicativos CLI."
}
}
@@ -0,0 +1,6 @@
{
"meta": {
"title": "Подключение аккаунта CLI",
"description": "Раздел аккаунта, метка у заголовка, подсказка при включении и уведомления на странице «Плагины» для плагинов CLI-приложений."
}
}
@@ -0,0 +1,6 @@
{
"meta": {
"title": "CLI 账号连接",
"description": "在插件页为 CLI 应用插件提供账号区块、标题标签、开启引导与提示。"
}
}
+28 -3
View File
@@ -1,6 +1,6 @@
{
"name": "@deepseek-ai/dsh-client-ui-cli-account",
"description": "Shared Plugins page pieces for CLI app plugins: the account connection mirror and components, linked into the Web shell",
"description": "CLI account surfaces for CLI app plugins: the account section, title tag, activation prompt, and notices on the Plugins page, over each plugin's account Remote",
"version": "0.2.2-alpha.2",
"publishConfig": {
"access": "public"
@@ -18,8 +18,27 @@
"types": "./lib/types/index.d.ts",
"default": "./lib/index.js"
},
"./client": {
"types": "./lib/types/client/index.d.ts",
"default": "./lib/client.js"
},
"./src/*": "./src/*",
"./package.json": "./package.json"
"./package.json": "./package.json",
"./locale/*.json": "./locale/*.json"
},
"dsh": {
"client": {
"inject": [
"@deepseek-ai/dsh-api-remotes",
"@deepseek-ai/dsh-client-ui-layout",
"@deepseek-ai/dsh-client-ui-plugin-manager"
],
"platform": "web"
}
},
"scripts": {
"bundle": "tsdown",
"watch": "tsdown --watch"
},
"license": "MIT",
"peerDependencies": {
@@ -28,10 +47,15 @@
"devDependencies": {
"@deepseek-ai/cordis": "workspace:~",
"@deepseek-ai/dsh-api-gateway": "workspace:*",
"@deepseek-ai/dsh-api-remotes": "workspace:*",
"@deepseek-ai/dsh-cli-account": "workspace:*",
"@deepseek-ai/dsh-client-locale": "workspace:*",
"@deepseek-ai/dsh-client-store": "workspace:*",
"@deepseek-ai/dsh-client-test-runtime": "workspace:*",
"@deepseek-ai/dsh-client-ui-layout": "workspace:*",
"@deepseek-ai/dsh-client-ui-plugin-manager": "workspace:*",
"@deepseek-ai/dsh-client-ui-primitives": "workspace:*",
"@deepseek-ai/dsh-client-ui-renderer": "workspace:*",
"@deepseek-ai/dsh-client-ui-slots": "workspace:*",
"@deepseek-ai/dsh-typert-protocol": "workspace:*",
"@testing-library/react": "^16.3.3",
@@ -39,8 +63,9 @@
"react-dom": "^18.2.0"
},
"files": [
"locale/*.json",
"lib/index.js",
"lib/**/*.css",
"lib/client.js",
"lib/types/**/*.d.ts"
]
}
@@ -1,21 +1,18 @@
/** Plugins page components shared by CLI plugins: they render a plugin's display phase with the copy the plugin translates. */
import { useEffect, type ReactNode } from 'react'
/**
* The account surfaces of one registered CLI plugin: the section, title tag, activation prompt, confirmation, and notice,
* with the slot entries that read them from the registration's face.
*/
import { useEffect, useState, type ReactNode } from 'react'
import { Button, IconWarningOutlineRegular, Modal, StateDot, Tag, Toast, type StateDotState, type TagTone } from '@deepseek-ai/dsh-client-ui-primitives'
import type { Translate } from '@deepseek-ai/dsh-client-ui-slots'
import type { CliCommandFailure } from '@deepseek-ai/dsh-cli-account/types'
import type { CliAccountNotice } from './connection.ts'
import type { InjectFace, PropsRuntime, Translate } from '@deepseek-ai/dsh-client-ui-slots'
import type {} from '@deepseek-ai/dsh-client-ui-plugin-manager/client'
import css from './CliAccount.module.css'
import type {
CliAccountAction, CliAccountConfirmation, CliAccountDisplay, CliAccountFace, CliAccountFailure, CliAccountKey, CliAccountNotice,
CliAccountPhase,
} from './types.ts'
/** What the page shows about a plugin's account; each plugin maps its own account states onto these phases. */
export type CliAccountPhase = 'checking' | 'connecting' | 'connected' | 'disconnected' | 'unavailable' | 'stopped'
/** Dictionary keys every CLI plugin translates for the shared components. */
export type CliAccountKey =
| 'section.title' | 'hint' | 'close' | 'action.cancel' | 'action.connect'
| 'activation.title' | 'activation.body' | 'activation.later'
| 'failure.details' | 'failure.exitCode'
| `badge.${Exclude<CliAccountPhase, 'checking'>}`
| `status.${Exclude<CliAccountPhase, 'connecting'>}`
type FaceProps = InjectFace<CliAccountFace> & { t: Translate<CliAccountKey> }
const TONE: Record<CliAccountPhase, StateDotState> = {
checking: 'ongoing', connecting: 'ongoing', connected: 'done', disconnected: 'idle', unavailable: 'warning', stopped: 'warning',
@@ -25,47 +22,14 @@ const BADGE_TONE: Record<Exclude<CliAccountPhase, 'checking'>, TagTone> = {
connecting: 'info', connected: 'success', disconnected: 'outline', unavailable: 'warning', stopped: 'warning',
}
/** One button in the section; the section disables it while an action is pending or the Host stream is down. */
export interface CliAccountAction {
readonly label: string
readonly onClick: () => void
/** Defaults to an outline button. */
readonly variant?: 'primary' | 'ghost'
}
/** One extra row under the status line, such as the linked app, with an optional button. */
export interface CliAccountNote {
readonly text: string
readonly action?: CliAccountAction
}
/** A failed operation as the section reports it. */
export interface CliAccountFailure {
/** The plugin's recovery guidance. */
readonly text: string
/** The Host's classified command, shown as a diagnostic after the guidance. */
readonly command?: CliCommandFailure | undefined
/** The plugin's allowlisted classification fields, appended in order; undefined entries are skipped. */
readonly details?: readonly (string | undefined)[]
}
/** What the section shows about one plugin's account. */
export interface CliAccountSectionProps {
export interface CliAccountSectionProps extends CliAccountDisplay {
readonly t: Translate<CliAccountKey>
readonly packageName: string
readonly phase: CliAccountPhase
/** The status label; defaults to the `status.*` copy for the phase, with `connecting` labelled as checking. */
readonly status?: string | undefined
/** Whether an action this page started has not answered. */
readonly busy: boolean
/** Whether the Host stream is delivering; buttons stay enabled while stopped so retry can reopen it. */
readonly linked: boolean
readonly actions: readonly CliAccountAction[]
readonly detail?: string | undefined
readonly notes?: readonly CliAccountNote[]
readonly failure?: CliAccountFailure | undefined
/** Extra content rendered last, such as confirmation dialogs. */
readonly children?: ReactNode
}
function describe(t: Translate<CliAccountKey>, failure: CliAccountFailure): string | undefined {
@@ -81,15 +45,19 @@ function describe(t: Translate<CliAccountKey>, failure: CliAccountFailure): stri
/**
* The account section on a plugin's bundle page.
* @param props - the phase, status, buttons, rows, and failure, with the plugin's translator.
* @returns the title, status line, detail, rows, failure, hint, and children.
* @param props - the plugin's display, the page state, and the plugin's translator.
* @returns the title, status line, detail, rows, failure, hint, and the confirmation an action asked for.
*/
export function CliAccountSection(props: CliAccountSectionProps): ReactNode {
const { t, packageName, phase, status, busy, linked, actions, detail, notes = [], failure, children } = props
const { t, packageName, phase, status, busy, linked, actions = [], detail, notes = [], failure } = props
const [confirming, setConfirming] = useState<{ readonly action: CliAccountAction; readonly confirm: CliAccountConfirmation }>()
// Reopening a stopped stream is the one action that does not need the Host stream.
const disabled = busy || (!linked && phase !== 'stopped')
const button = (action: CliAccountAction): ReactNode =>
<Button key={action.label} variant={action.variant ?? 'outline'} size="sm" disabled={disabled} onClick={action.onClick}>{action.label}</Button>
const button = (action: CliAccountAction): ReactNode => {
const { confirm } = action
const onClick = confirm === undefined ? action.onClick : () => { setConfirming({ action, confirm }) }
return <Button key={action.label} variant={action.variant ?? 'outline'} size="sm" disabled={disabled} onClick={onClick}>{action.label}</Button>
}
const diagnostic = failure === undefined ? undefined : describe(t, failure)
return (
<div className={css.section} data-cli-account={phase} data-cli-account-package={packageName}>
@@ -108,7 +76,10 @@ export function CliAccountSection(props: CliAccountSectionProps): ReactNode {
))}
{failure === undefined ? null : <p className={css.failure} role="alert">{failure.text}{diagnostic === undefined ? null : <> {diagnostic}</>}</p>}
<p className={css.hint}>{t('hint')}</p>
{children}
{confirming === undefined ? null : (
<CliAccountConfirm t={t} confirmation={confirming.confirm}
onClose={() => { setConfirming(undefined) }} onConfirm={confirming.action.onClick} />
)}
</div>
)
}
@@ -166,51 +137,94 @@ export function CliAccountActivation({ t, phase, onDismiss, onConnect }: CliAcco
)
}
/** A confirmation's copy and callbacks, with the plugin's translator for the shared buttons. */
/** The question, its callbacks, and the plugin's translator for the shared buttons. */
export interface CliAccountConfirmProps {
readonly t: Translate<CliAccountKey>
readonly open: boolean
readonly title: string
readonly body: string
readonly confirm: string
readonly confirmation: CliAccountConfirmation
readonly onClose: () => void
readonly onConfirm: () => void
}
/**
* Confirm an action that changes the account outside DSH, such as signing out of a CLI the terminal shares.
* @param props - whether it is open, its copy, and the close and confirm callbacks.
* Confirm an action that changes the account outside DSH.
* @param props - the question and the close and confirm callbacks.
* @returns a dialog that closes before it confirms.
*/
export function CliAccountConfirm({ t, open, title, body, confirm, onClose, onConfirm }: CliAccountConfirmProps): ReactNode {
export function CliAccountConfirm({ t, confirmation, onClose, onConfirm }: CliAccountConfirmProps): ReactNode {
return (
<Modal open={open} title={title} closeLabel={t('close')} onClose={onClose}
<Modal open title={confirmation.title} closeLabel={t('close')} onClose={onClose}
footer={<>
<Button variant="ghost" onClick={onClose}>{t('action.cancel')}</Button>
<Button variant="primary" data-modal-autofocus onClick={() => { onClose(); onConfirm() }}>{confirm}</Button>
<Button variant="primary" data-modal-autofocus onClick={() => { onClose(); onConfirm() }}>{confirmation.label}</Button>
</>}>
<p>{body}</p>
<p>{confirmation.body}</p>
</Modal>
)
}
/** The latest notice, with the plugin's translator for `notice.*` copy. */
export interface CliAccountToastProps<Notice extends string> {
readonly t: Translate<`notice.${NoInfer<CliAccountNotice<Notice>['kind']>}`>
readonly notice: CliAccountNotice<Notice> | undefined
/** The latest notice, the plugin's success copy, and its dismissal. */
export interface CliAccountToastProps {
readonly t: Translate<CliAccountKey>
readonly notice: CliAccountNotice<string> | undefined
readonly notices: Readonly<Partial<Record<string, () => string>>>
readonly onDone: () => void
}
/**
* Account outcomes reported outside the Plugins panel's lifetime.
* @param props - the latest notice, its dismissal, and the plugin's translator.
* @returns the toast for the notice, or null.
* @param props - the latest notice, the plugin's success copy, its dismissal, and the plugin's translator.
* @returns the toast for the notice, or null when there is none or its operation has no copy.
*/
export function CliAccountToast<Notice extends string>({ t, notice, onDone }: CliAccountToastProps<Notice>): ReactNode {
export function CliAccountToast({ t, notice, notices, onDone }: CliAccountToastProps): ReactNode {
if (notice === undefined) return null
const failed = notice.kind === 'action-failed'
return (
<Toast key={notice.seq} text={t(`notice.${notice.kind}`)} onDone={onDone}
{...failed ? { icon: <IconWarningOutlineRegular /> } : { tone: 'success' as const }} />
)
if (notice.kind === 'action-failed') {
return <Toast key={notice.seq} text={t('notice.action-failed')} icon={<IconWarningOutlineRegular />} onDone={onDone} />
}
const text = notices[notice.operation]
return text === undefined ? null : <Toast key={notice.seq} text={text()} tone="success" onDone={onDone} />
}
/**
* The `plugins.bundle.config` entry.
* @param props - the registration's face and the plugin's translator.
* @returns the section for the current snapshot.
*/
export function CliAccountSectionEntry({ useCliAccount, present, page, packageName, t }: FaceProps): ReactNode {
const snapshot = useCliAccount(value => value)
return <CliAccountSection {...present(snapshot, page)} t={t} packageName={packageName} busy={snapshot.busy} linked={snapshot.linked} />
}
/**
* The `plugins.detail.badge` entry.
* @param props - the open detail page's subject, the registration's face, and the plugin's translator.
* @returns the tag for the registration's bundle, or null on any other page.
*/
export function CliAccountBadgeEntry(props: FaceProps & PropsRuntime<'plugins.detail.badge'>): ReactNode {
const { useCliAccount, present, page, packageName, subject, t } = props
const phase = useCliAccount(value => present(value, page).phase)
return <CliAccountBadge t={t} subject={subject} packageName={packageName} phase={phase} />
}
/**
* The `plugins.bundle.activation` entry; Connect opens the bundle page and runs the section's first primary action
* that asks no confirmation.
* @param props - activation callbacks, the registration's face, and the plugin's translator.
* @returns the prompt for the current snapshot.
*/
export function CliAccountActivationEntry(props: FaceProps & PropsRuntime<'plugins.bundle.activation'>): ReactNode {
const { useCliAccount, present, page, onDismiss, onOpenDetails, t } = props
const display = present(useCliAccount(value => value), page)
const connect = display.actions?.find(action => action.variant === 'primary' && action.confirm === undefined)
const onConnect = (): void => { onOpenDetails(); connect?.onClick() }
return <CliAccountActivation t={t} phase={display.phase} onDismiss={onDismiss} onConnect={onConnect} />
}
/**
* The `shell.overlay` entry.
* @param props - the registration's face and the plugin's translator.
* @returns the toast for the latest notice, or null.
*/
export function CliAccountToastEntry({ useCliAccount, notices, dismissNotice, t }: FaceProps): ReactNode {
const notice = useCliAccount(value => value.notice)
return <CliAccountToast t={t} notice={notice} notices={notices} onDone={dismissNotice} />
}
@@ -1,43 +1,16 @@
/** Browser mirror of one CLI plugin's Host account view and the Plugins page's account actions. */
import type { Context } from '@deepseek-ai/cordis'
import type { RemoteStream } from '@deepseek-ai/dsh-api-gateway/client'
import type { CliAccountView, CliOperationId } from '@deepseek-ai/dsh-cli-account/types'
import type { CliOperationId } from '@deepseek-ai/dsh-cli-account/types'
import { createSnapshotStore, type SnapshotStore } from '@deepseek-ai/dsh-client-store'
import type { RemoteResult } from '@deepseek-ai/dsh-typert-protocol'
import type {
AnyCliAccountView, CliAccountNotice, CliAccountPage, CliAccountRegistration, CliAccountSnapshot, CliOperationKindOf,
} from './types.ts'
type AnyView = CliAccountView<unknown, string, string>
type KindOf<View extends AnyView> = NonNullable<View['result']>['kind']
/** A transient outcome the page reports outside its own lifetime; `seq` distinguishes repeats. */
export interface CliAccountNotice<Notice extends string> {
readonly seq: number
readonly kind: Notice | 'action-failed'
}
/** The page's whole view: the Host's account view plus this browser's pending action and notice. */
export interface CliAccountSnapshot<View extends AnyView, Notice extends string> {
/** The Host's view; undefined until the stream reports one. */
readonly view: View | undefined
/** Whether the Host stream is delivering. */
readonly linked: boolean
/** Whether the Host stream failed for good, as when the plugin's Host component is not running; `retry` reopens it. */
readonly stopped: boolean
/** Whether an action this page started has not answered. */
readonly busy: boolean
readonly notice: CliAccountNotice<Notice> | undefined
}
/** The plugin's Remote operations the mirror uses and the notices its successes report. */
export interface CliAccountConnectionOptions<View extends AnyView, Notice extends string> {
/** Diagnostic name of the Host stream. */
readonly name: string
/** Open one generation of the plugin's `follow` stream. */
readonly follow: (signal: AbortSignal) => AsyncIterable<View>
/** Cancel one operation through the plugin's Remote. */
readonly cancel: (id: CliOperationId) => Promise<RemoteResult<void>>
/** The notice each operation kind reports when an operation this browser started succeeds; unlisted kinds report none. */
readonly notices: Readonly<Partial<Record<KindOf<View>, Notice>>>
}
/** The registration's Remote operations and notices, with the Host stream's diagnostic name. */
export type CliAccountConnectionOptions<View extends AnyCliAccountView> =
Pick<CliAccountRegistration<View>, 'follow' | 'cancel' | 'notices'> & { readonly name: string }
function openAuthorizationPage(url: string | undefined): void {
if (url !== undefined && URL.canParse(url) && new URL(url).protocol === 'https:') window.open(url, '_blank', 'noopener,noreferrer')
@@ -49,10 +22,10 @@ async function settle<T>(call: Promise<RemoteResult<T>>): Promise<T> {
return result.value
}
/** One Host subscription per plugin page, shared by every surface of that plugin on the Plugins page. */
export class CliAccountConnection<View extends AnyView, Notice extends string> {
/** One Host subscription per registered account, shared by every surface of that account on the Plugins page. */
export class CliAccountConnection<View extends AnyCliAccountView> {
/** The page's whole view, published after each stream item or page action settles. */
readonly state: SnapshotStore<CliAccountSnapshot<View, Notice>> = createSnapshotStore<CliAccountSnapshot<View, Notice>>({
readonly state: SnapshotStore<CliAccountSnapshot<View>> = createSnapshotStore<CliAccountSnapshot<View>>({
view: undefined, linked: false, stopped: false, busy: false, notice: undefined,
})
@@ -66,19 +39,22 @@ export class CliAccountConnection<View extends AnyView, Notice extends string> {
private stream!: RemoteStream<View>
private observing!: Promise<void>
/** The page actions every plugin's face exposes unchanged, bound so slot handlers can call them directly. */
readonly actions = {
cancel: (): void => { this.cancel() },
openAuthorization: (): void => { this.openAuthorization() },
retry: (): void => { this.retry() },
dismissNotice: (): void => { this.dismissNotice() },
/** The page actions, bound so a plugin's buttons can call them directly. */
readonly page: CliAccountPage = {
start: (call) => { this.start(call) },
cancel: () => { this.cancel() },
openAuthorization: () => { this.openAuthorization() },
retry: () => { this.retry() },
}
/** Clear the current notice; bound for the notice's dismissal. */
readonly dismissNotice = (): void => { this.patch({ notice: undefined }) }
/**
* @param ctx - the plugin's browser context, carrying the Remote client.
* @param options - the plugin's Remote operations and success notices.
* @param ctx - the browser context carrying the Remote client.
* @param options - the plugin's Remote operations and success notices, and the stream's diagnostic name.
*/
constructor(private readonly ctx: Context, private readonly options: CliAccountConnectionOptions<View, Notice>) {
constructor(private readonly ctx: Context, private readonly options: CliAccountConnectionOptions<View>) {
this.subscribe()
}
@@ -119,11 +95,6 @@ export class CliAccountConnection<View extends AnyView, Notice extends string> {
void this.reopen()
}
/** Clear the current notice. */
dismissNotice(): void {
this.patch({ notice: undefined })
}
/**
* Stop observing the Host; afterwards the page opens no link, reports nothing more, and a pending retry opens no
* stream. Host-owned operations keep running.
@@ -177,8 +148,10 @@ export class CliAccountConnection<View extends AnyView, Notice extends string> {
const result = view.result
if (result?.id !== started.id) return
this.started = undefined
const notice = result.outcome === 'succeeded' ? this.options.notices[result.kind as KindOf<View>] : undefined
if (notice !== undefined) this.notify(notice)
const operation = result.kind as CliOperationKindOf<View>
if (result.outcome === 'succeeded' && this.options.notices[operation] !== undefined) {
this.notify({ kind: 'succeeded', operation })
}
}
private async run(operation: () => Promise<void>): Promise<void> {
@@ -188,19 +161,22 @@ export class CliAccountConnection<View extends AnyView, Notice extends string> {
await operation()
} catch {
// The Host keeps the diagnostic; the page reports one retryable outcome.
this.notify('action-failed')
this.notify({ kind: 'action-failed' })
} finally {
this.patch({ busy: false })
}
}
private patch(change: Partial<CliAccountSnapshot<View, Notice>>): void {
private patch(change: Partial<CliAccountSnapshot<View>>): void {
this.state.set({ ...this.state.getSnapshot(), ...change })
}
private notify(kind: CliAccountNotice<Notice>['kind']): void {
private notify(
notice: { readonly kind: 'succeeded'; readonly operation: CliOperationKindOf<View> } | { readonly kind: 'action-failed' },
): void {
if (this.disposed) return
this.seq += 1
this.patch({ notice: { seq: this.seq, kind } })
const next: CliAccountNotice<CliOperationKindOf<View>> = { ...notice, seq: this.seq }
this.patch({ notice: next })
}
}
@@ -0,0 +1,62 @@
/**
* CLI account surfaces for CLI app plugins, browser half. `ctx.cliAccounts` shows a plugin's account section, title tag,
* activation prompt, and notices on its bundle's Plugins page, following the plugin's Host account Remote.
*/
import type { Context } from '@deepseek-ai/cordis'
import type {} from '@deepseek-ai/dsh-api-remotes/client'
import type {} from '@deepseek-ai/dsh-client-ui-layout/client'
import type {} from '@deepseek-ai/dsh-client-ui-plugin-manager/client'
import type {} from '@deepseek-ai/dsh-client-ui-renderer/client'
import { CliAccountActivationEntry, CliAccountBadgeEntry, CliAccountSectionEntry, CliAccountToastEntry } from './components.tsx'
import { CliAccountConnection } from './connection.ts'
import type { AnyCliAccountView, CliAccountFace, CliAccountRegistration, CliAccounts } from './types.ts'
export type {
AnyCliAccountView, CliAccountAction, CliAccountConfirmation, CliAccountDisplay, CliAccountFailure, CliAccountKey,
CliAccountNamespace, CliAccountNote, CliAccountNotice, CliAccountPage, CliAccountPhase, CliAccountRegistration, CliAccounts,
CliAccountSnapshot, CliOperationKindOf,
} from './types.ts'
declare module '@deepseek-ai/cordis' {
interface Context {
/** CLI app plugin account surfaces on the Plugins page. */
cliAccounts: CliAccounts
}
}
/** Services the Host stream and the slot registrations need. */
export const inject = ['remote', 'slots']
function register<View extends AnyCliAccountView>(ctx: Context, account: CliAccountRegistration<View>): () => void {
const { packageName, locale } = account
const dispose = ctx.effect(function* () {
const connection = new CliAccountConnection(ctx, { ...account, name: `${packageName} account` })
yield async () => { await connection.dispose() }
const face: CliAccountFace = {
hooks: { cliAccount: connection.state },
packageName, page: connection.page, present: account.present, notices: account.notices, dismissNotice: connection.dismissNotice,
}
yield ctx.slots.inject('plugins.bundle.config', () => ctx.slots.register({
name: 'plugins.bundle.config', key: packageName, locale, inject: () => face,
}, CliAccountSectionEntry))
yield ctx.slots.inject('plugins.bundle.activation', () => ctx.slots.register({
name: 'plugins.bundle.activation', key: packageName, locale, inject: () => face,
}, CliAccountActivationEntry))
yield ctx.slots.inject('plugins.detail.badge', () => ctx.slots.register({
name: 'plugins.detail.badge', id: `${packageName}.account`, locale, inject: () => face,
}, CliAccountBadgeEntry))
yield ctx.slots.inject('shell.overlay', () => ctx.slots.register({
name: 'shell.overlay', id: `${packageName}.account-toast`, locale, inject: () => face,
}, CliAccountToastEntry))
}, `cliAccounts.register(${packageName})`)
return () => void dispose()
}
/**
* Provide the account registry; each registration lives until its disposer runs or this plugin unloads.
* @param ctx - the browser plugin context.
*/
export function apply(ctx: Context): void {
const accounts: CliAccounts = { register: account => register(ctx, account) }
ctx.provide('cliAccounts', accounts)
}
@@ -0,0 +1,158 @@
/** Registration, display, and dictionary types a CLI app plugin uses to show its account on the Plugins page. */
import type { CliAccountView, CliCommandFailure, CliOperationId } from '@deepseek-ai/dsh-cli-account/types'
import type { HostObservable, LocaleNamespaceMap } from '@deepseek-ai/dsh-client-ui-slots'
import type { RemoteResult } from '@deepseek-ai/dsh-typert-protocol'
/** Any plugin's Host account view; each plugin supplies its own account, operation, and failure types. */
export type AnyCliAccountView = CliAccountView<unknown, string, string>
/** The operation kinds a plugin's view reports results for. */
export type CliOperationKindOf<View extends AnyCliAccountView> = NonNullable<View['result']>['kind']
/** What the page shows about a plugin's account; each plugin maps its own account states onto these phases. */
export type CliAccountPhase = 'checking' | 'connecting' | 'connected' | 'disconnected' | 'unavailable' | 'stopped'
/** Dictionary keys the shared surfaces read from every CLI plugin's namespace. */
export type CliAccountKey =
| 'section.title' | 'hint' | 'close' | 'action.cancel' | 'action.connect'
| 'activation.title' | 'activation.body' | 'activation.later'
| 'failure.details' | 'failure.exitCode' | 'notice.action-failed'
| `badge.${Exclude<CliAccountPhase, 'checking'>}`
| `status.${Exclude<CliAccountPhase, 'connecting'>}`
type LocaleNamespace = Extract<keyof LocaleNamespaceMap, string>
/** Locale namespaces whose dictionary translates every {@link CliAccountKey}. */
export type CliAccountNamespace = {
[N in LocaleNamespace]: [CliAccountKey] extends [LocaleNamespaceMap[N]] ? N : never
}[LocaleNamespace]
/** A transient outcome the page reports outside its own lifetime; `seq` distinguishes repeats. */
export type CliAccountNotice<Kind extends string> =
| { readonly seq: number; readonly kind: 'succeeded'; readonly operation: Kind }
| { readonly seq: number; readonly kind: 'action-failed' }
/** The page's whole view: the Host's account view plus this browser's stream state, pending action, and notice. */
export interface CliAccountSnapshot<View extends AnyCliAccountView> {
/** The Host's view; undefined until the stream reports one. */
readonly view: View | undefined
/** Whether the Host stream is delivering. */
readonly linked: boolean
/** Whether the Host stream failed for good, as when the plugin's Host component is not running; `retry` reopens it. */
readonly stopped: boolean
/** Whether an action this page started has not answered. */
readonly busy: boolean
readonly notice: CliAccountNotice<CliOperationKindOf<View>> | undefined
}
/** The page actions a plugin's buttons call. */
export interface CliAccountPage {
/**
* Start an operation through the plugin's Remote; a click while another action is pending is ignored. The page then
* follows the returned operation in place of any earlier one; a rejected start leaves it following none and reports
* the `action-failed` notice.
*/
readonly start: (call: () => Promise<RemoteResult<CliOperationId>>) => void
/** Cancel the current operation when the Host marks it cancellable. */
readonly cancel: () => void
/** Open the current operation's authorization link again, over HTTPS only. */
readonly openAuthorization: () => void
/** Reopen the Host stream after it stopped; ignored while it runs or while a reopen is pending. */
readonly retry: () => void
}
/** The question an action asks before it runs. */
export interface CliAccountConfirmation {
readonly title: string
readonly body: string
/** The confirm button's label. */
readonly label: string
}
/** One button in the section; the section disables it while an action is pending or the Host stream is down. */
export interface CliAccountAction {
readonly label: string
readonly onClick: () => void
/** Defaults to an outline button. */
readonly variant?: 'primary' | 'ghost'
/** Ask first, for an action that changes the account outside DSH, such as signing out of a CLI the terminal shares. */
readonly confirm?: CliAccountConfirmation
}
/** One extra row under the status line, such as the linked app, with an optional button. */
export interface CliAccountNote {
readonly text: string
readonly action?: CliAccountAction
}
/** A failed operation as the section reports it. */
export interface CliAccountFailure {
/** The plugin's recovery guidance. */
readonly text: string
/** The Host's classified command, shown as a diagnostic after the guidance. */
readonly command?: CliCommandFailure | undefined
/** The plugin's allowlisted classification fields, appended in order; undefined entries are skipped. */
readonly details?: readonly (string | undefined)[]
}
/** What the section shows; the plugin translates every string. */
export interface CliAccountDisplay {
readonly phase: CliAccountPhase
/** The status label; defaults to the `status.*` copy for the phase, with `connecting` labelled as checking. */
readonly status?: string | undefined
/** The first `primary` action that asks no confirmation also answers Connect in the activation prompt. */
readonly actions?: readonly CliAccountAction[]
readonly detail?: string | undefined
readonly notes?: readonly CliAccountNote[]
readonly failure?: CliAccountFailure | undefined
}
/** One CLI app plugin's account: its bundle page, dictionary, Remote operations, and presentation. */
export interface CliAccountRegistration<View extends AnyCliAccountView> {
/** npm package whose bundle page carries the section and tag. */
readonly packageName: string
/** The plugin's dictionary namespace, which supplies the {@link CliAccountKey} copy. */
readonly locale: CliAccountNamespace
/** Open one generation of the plugin's `follow` stream. */
readonly follow: (signal: AbortSignal) => AsyncIterable<View>
/** Cancel one operation through the plugin's Remote. */
readonly cancel: (id: CliOperationId) => Promise<RemoteResult<void>>
/**
* The translated notice each operation kind reports when an operation this browser started succeeds; unlisted kinds
* report none.
*/
readonly notices: Readonly<Partial<Record<CliOperationKindOf<View>, () => string>>>
/**
* Derive what the section shows. The surfaces call it while rendering, so it reads nothing else that changes outside
* React; translating through `ctx.locale.bind` follows the active language.
*/
readonly present: (snapshot: CliAccountSnapshot<View>, page: CliAccountPage) => CliAccountDisplay
}
/** The `ctx.cliAccounts` registry. */
export interface CliAccounts {
/**
* Show one account's section, title tag, activation prompt, and notices on the Plugins page.
* @param account - the bundle package, dictionary namespace, Remote operations, and presentation.
* @returns an idempotent disposer that removes the surfaces and closes the Host stream.
* @throws when another registration already occupies the package's bundle slots.
*/
register<View extends AnyCliAccountView>(account: CliAccountRegistration<View>): () => void
}
/** The face every surface entry of one registration injects. */
export interface CliAccountFace {
hooks: { cliAccount: HostObservable<CliAccountSnapshot<AnyCliAccountView>> }
readonly packageName: string
readonly page: CliAccountPage
readonly notices: Readonly<Partial<Record<string, () => string>>>
readonly dismissNotice: () => void
/**
* The registration's `present`. Method syntax lets the presenter typed by the plugin's own view stand in for one typed
* by any view.
* @param snapshot - the page snapshot the surface rendered from.
* @param page - the page actions.
* @returns the section's display.
*/
present(snapshot: CliAccountSnapshot<AnyCliAccountView>, page: CliAccountPage): CliAccountDisplay
}
+7 -9
View File
@@ -1,11 +1,9 @@
/**
* Shared Plugins page pieces of CLI app plugins: the connection mirror and the account components. The Web shell links
* this library statically and shares one copy through its module table; plugins import it like any platform module.
* CLI account surfaces plugin, Node half. Pure UI plugin: the empty apply
* exists so the plugin appears in the host cordis.yml / Loader; the browser
* half ships via exports["./client"], discovered through the package.json
* dsh.client declaration.
*/
export {
CliAccountActivation, CliAccountBadge, CliAccountConfirm, CliAccountSection, CliAccountToast,
type CliAccountAction, type CliAccountActivationProps, type CliAccountBadgeProps, type CliAccountBadgeSubject,
type CliAccountConfirmProps, type CliAccountFailure,
type CliAccountKey, type CliAccountNote, type CliAccountPhase, type CliAccountSectionProps, type CliAccountToastProps,
} from './components.tsx'
export { CliAccountConnection, type CliAccountConnectionOptions, type CliAccountNotice, type CliAccountSnapshot } from './connection.ts'
/** Host plugin body — no host-side behavior for this surface plugin. */
export function apply(): void {}
@@ -1,18 +1,22 @@
// @vitest-environment jsdom
/** The section, tag, activation prompt, confirmation, and notice render a plugin's display phase with the copy it translates. */
/** The section, tag, activation prompt, confirmation, and notice render a plugin's display with the copy it translates. */
import type { ComponentProps } from 'react'
import { cleanup, fireEvent, render, screen } from '@testing-library/react'
import { makeTranslate } from '@deepseek-ai/dsh-client-test-runtime'
import { afterEach, expect, it, vi } from 'vitest'
import {
CliAccountActivation, CliAccountBadge, CliAccountConfirm, CliAccountSection, CliAccountToast,
type CliAccountBadgeSubject, type CliAccountKey, type CliAccountPhase, type CliAccountSectionProps,
} from '../src/index.ts'
CliAccountActivation, CliAccountActivationEntry, CliAccountBadge, CliAccountBadgeEntry, CliAccountSection, CliAccountSectionEntry,
CliAccountToast, CliAccountToastEntry, type CliAccountBadgeSubject, type CliAccountSectionProps,
} from '../src/client/components.tsx'
import type {
AnyCliAccountView, CliAccountDisplay, CliAccountKey, CliAccountPage, CliAccountPhase, CliAccountSnapshot,
} from '../src/client/types.ts'
afterEach(cleanup)
const PACKAGE = '@acme/fixture'
const copy: Record<CliAccountKey | 'notice.connected' | 'notice.action-failed', string> = {
const copy: Record<CliAccountKey, string> = {
'section.title': 'Fixture account',
hint: 'Shared with the terminal.',
close: 'Close',
@@ -23,6 +27,7 @@ const copy: Record<CliAccountKey | 'notice.connected' | 'notice.action-failed',
'activation.later': 'Later',
'failure.details': 'Diagnostic: {details}',
'failure.exitCode': 'exit {code}',
'notice.action-failed': 'Try again',
'badge.connecting': 'Tag connecting',
'badge.connected': 'Tag connected',
'badge.disconnected': 'Tag disconnected',
@@ -33,14 +38,12 @@ const copy: Record<CliAccountKey | 'notice.connected' | 'notice.action-failed',
'status.disconnected': 'Not connected',
'status.unavailable': 'Cannot confirm',
'status.stopped': 'Not running',
'notice.connected': 'Fixture connected',
'notice.action-failed': 'Try again',
}
const t = makeTranslate(copy)
const button = (name: string) => screen.getByRole('button', { name })
function section(props: Partial<CliAccountSectionProps> = {}) {
return <CliAccountSection t={t} packageName={PACKAGE} phase="disconnected" busy={false} linked actions={[]} {...props} />
return <CliAccountSection t={t} packageName={PACKAGE} phase="disconnected" busy={false} linked {...props} />
}
it('labels each phase from the shared copy unless the plugin passes a step', () => {
@@ -55,19 +58,17 @@ it('labels each phase from the shared copy unless the plugin passes a step', ()
expect(screen.getByText('Step 1')).toBeTruthy()
})
it('renders the plugin buttons, detail, notes, and children, and disables buttons while acting or offline', () => {
it('renders the plugin buttons, detail, and notes, and disables buttons while acting or offline', () => {
const connect = vi.fn()
const replace = vi.fn()
const props: Partial<CliAccountSectionProps> = {
actions: [{ label: 'Link', onClick: connect, variant: 'primary' }, { label: 'Retry', onClick: vi.fn() }],
detail: 'Link an app first.',
notes: [{ text: 'App: cli_a', action: { label: 'Change', onClick: replace, variant: 'ghost' } }, { text: 'Plain note' }],
children: <span>child</span>,
}
const { rerender } = render(section(props))
expect(screen.getByText('Link an app first.')).toBeTruthy()
expect(screen.getByText('Plain note')).toBeTruthy()
expect(screen.getByText('child')).toBeTruthy()
fireEvent.click(button('Link'))
fireEvent.click(button('Change'))
expect(connect).toHaveBeenCalledOnce()
@@ -82,6 +83,29 @@ it('renders the plugin buttons, detail, notes, and children, and disables button
expect(disabled()).toEqual([false, false, false])
})
it('asks before an action that changes the account outside DSH and runs it only after the user accepts', () => {
const signOut = vi.fn()
const replace = vi.fn()
render(section({
phase: 'connected',
actions: [{ label: 'Sign out', onClick: signOut, confirm: { title: 'Sign out?', body: 'This signs out the terminal too.', label: 'Sign out now' } }],
notes: [{ text: 'App: cli_a', action: { label: 'Change', onClick: replace, confirm: { title: 'Change app?', body: 'Link another app.', label: 'Change app' } } }],
}))
fireEvent.click(button('Sign out'))
expect(screen.getByRole('dialog', { name: 'Sign out?' })).toBeTruthy()
expect(screen.getByText('This signs out the terminal too.')).toBeTruthy()
fireEvent.click(button('Cancel'))
expect(screen.queryByRole('dialog')).toBeNull()
expect(signOut).not.toHaveBeenCalled()
fireEvent.click(button('Sign out'))
fireEvent.click(button('Sign out now'))
expect(screen.queryByRole('dialog')).toBeNull()
expect(signOut).toHaveBeenCalledOnce()
fireEvent.click(button('Change'))
fireEvent.click(button('Change app'))
expect(replace).toHaveBeenCalledOnce()
})
it.each<[string, CliAccountSectionProps['failure'], string]>([
['the failed command, exit code, and plugin details', { text: 'Failed.', command: { command: 'login', exitCode: 3 }, details: ['internal', undefined, 'sdk_error'] }, 'Failed. Diagnostic: login · exit 3 · internal · sdk_error'],
['a command that produced no exit', { text: 'Failed.', command: { command: 'status', exitCode: null } }, 'Failed. Diagnostic: status'],
@@ -132,24 +156,76 @@ it('prompts to connect only while disconnected and steps aside once the phase se
expect(onDismiss).toHaveBeenCalledTimes(2)
})
it('confirms an action only after the user accepts it', () => {
const onClose = vi.fn()
const onConfirm = vi.fn()
render(<CliAccountConfirm t={t} open title="Sign out?" body="This signs out the terminal too." confirm="Sign out" onClose={onClose} onConfirm={onConfirm} />)
expect(screen.getByText('This signs out the terminal too.')).toBeTruthy()
fireEvent.click(button('Cancel'))
expect(onConfirm).not.toHaveBeenCalled()
fireEvent.click(button('Sign out'))
expect(onClose).toHaveBeenCalledTimes(2)
expect(onConfirm).toHaveBeenCalledOnce()
it('shows the latest notice with the plugin copy or the shared failure copy', () => {
const onDone = vi.fn()
const notices = { connect: () => 'Fixture connected' }
const toast = (notice: Parameters<typeof CliAccountToast>[0]['notice']) =>
<CliAccountToast t={t} notice={notice} notices={notices} onDone={onDone} />
const { rerender } = render(toast(undefined))
expect(document.body.textContent).toBe('')
rerender(toast({ seq: 1, kind: 'succeeded', operation: 'connect' }))
expect(screen.getByText('Fixture connected')).toBeTruthy()
rerender(toast({ seq: 2, kind: 'action-failed' }))
expect(screen.getByText('Try again')).toBeTruthy()
rerender(toast({ seq: 3, kind: 'succeeded', operation: 'check' }))
expect(document.body.textContent).toBe('')
})
it('shows the latest notice with the success or failure tone', () => {
const onDone = vi.fn()
const { rerender } = render(<CliAccountToast<'connected'> t={t} notice={undefined} onDone={onDone} />)
expect(document.body.textContent).toBe('')
rerender(<CliAccountToast<'connected'> t={t} notice={{ seq: 1, kind: 'connected' }} onDone={onDone} />)
function face(snapshot: Partial<CliAccountSnapshot<AnyCliAccountView>>, display: CliAccountDisplay) {
const current: CliAccountSnapshot<AnyCliAccountView> = {
view: undefined, linked: true, stopped: false, busy: false, notice: undefined, ...snapshot,
}
const page: CliAccountPage = { start: vi.fn(), cancel: vi.fn(), openAuthorization: vi.fn(), retry: vi.fn() }
const present = vi.fn((_snapshot: CliAccountSnapshot<AnyCliAccountView>, _page: CliAccountPage) => display)
return {
useCliAccount: <R,>(selector: (value: CliAccountSnapshot<AnyCliAccountView>) => R): R => selector(current),
packageName: PACKAGE, page, present, notices: { connect: () => 'Fixture connected' }, dismissNotice: vi.fn(), t,
}
}
it('renders the section from the registration presenter with the page state', () => {
const props = face({ busy: true }, { phase: 'connected', detail: 'Signed in as Ada.', actions: [{ label: 'Check', onClick: vi.fn() }] })
render(<CliAccountSectionEntry {...props} />)
expect(props.present).toHaveBeenCalledWith(expect.objectContaining({ busy: true }), props.page)
expect(screen.getByText('Signed in as Ada.')).toBeTruthy()
expect((button('Check') as HTMLButtonElement).disabled).toBe(true)
})
it('tags the bundle with the presenter phase', () => {
const props = face({}, { phase: 'unavailable' })
const subject = { kind: 'bundle', pkg: { name: PACKAGE, installed: true, availability: 'profile', official: false, enabled: true, rows: [] } } as const
render(<CliAccountBadgeEntry {...{ ...props, subject } as ComponentProps<typeof CliAccountBadgeEntry>} />)
expect(screen.getByText('Tag unavailable')).toBeTruthy()
})
it('connects from the prompt through the first primary action that asks nothing', () => {
const ask = vi.fn()
const connect = vi.fn()
const onOpenDetails = vi.fn()
const props = face({}, {
phase: 'disconnected',
actions: [
{ label: 'Retry', onClick: vi.fn() },
{ label: 'Reset', onClick: ask, variant: 'primary', confirm: { title: 'Reset?', body: 'Resets the CLI.', label: 'Reset' } },
{ label: 'Link app', onClick: connect, variant: 'primary' },
],
})
const prompt = (face: typeof props) =>
<CliAccountActivationEntry {...{ ...face, onDismiss: vi.fn(), onOpenDetails } as ComponentProps<typeof CliAccountActivationEntry>} />
const { rerender } = render(prompt(props))
fireEvent.click(button('Connect'))
expect(onOpenDetails).toHaveBeenCalledOnce()
expect(connect).toHaveBeenCalledOnce()
expect(ask).not.toHaveBeenCalled()
const bare = face({}, { phase: 'disconnected' })
rerender(prompt(bare))
fireEvent.click(button('Connect'))
expect(onOpenDetails).toHaveBeenCalledTimes(2)
})
it('shows the registration notice', () => {
const props = face({ notice: { seq: 1, kind: 'succeeded', operation: 'connect' } }, { phase: 'connected' })
render(<CliAccountToastEntry {...props} />)
expect(screen.getByText('Fixture connected')).toBeTruthy()
rerender(<CliAccountToast<'connected'> t={t} notice={{ seq: 2, kind: 'action-failed' }} onDone={onDone} />)
expect(screen.getByText('Try again')).toBeTruthy()
})
@@ -5,10 +5,9 @@ import type { RemoteStreamOptions } from '@deepseek-ai/dsh-api-gateway/client'
import type { CliAccountView, CliOperationId } from '@deepseek-ai/dsh-cli-account/types'
import { RemoteError, type RemoteResult } from '@deepseek-ai/dsh-typert-protocol'
import { expect, it, onTestFinished, vi } from 'vitest'
import { CliAccountConnection } from '../src/index.ts'
import { CliAccountConnection } from '../src/client/connection.ts'
type View = CliAccountView<{ readonly state: 'out' | 'in' }, 'check' | 'connect' | 'leave', 'authorizing' | 'leaving'>
type Notice = 'connected' | 'left'
const OP = 'op-1' as CliOperationId
const OUT: View = { account: { state: 'out' } }
@@ -55,8 +54,8 @@ function fixture() {
},
})
const windowOpen = vi.spyOn(window, 'open').mockReturnValue(null)
const connection = new CliAccountConnection<View, Notice>(ctx, {
name: 'Fixture connection', follow, cancel, notices: { connect: 'connected', leave: 'left' },
const connection = new CliAccountConnection<View>(ctx, {
name: 'Fixture connection', follow, cancel, notices: { connect: () => 'Connected', leave: () => 'Left' },
})
onTestFinished(async () => { await connection.dispose(); windowOpen.mockRestore(); await ctx.fiber.dispose() })
return {
@@ -98,18 +97,18 @@ it('mirrors the Host view through the plugin stream', async () => {
it('opens each new link of an operation this browser started once and reports mapped successes', async () => {
const b = fixture()
await b.publish(OUT)
b.connection.start(b.start)
b.connection.page.start(b.start)
await settle(b)
await b.publish({ ...OUT, operation: operation('connect', 'authorizing', { url: 'https://example.com/a', cancellable: true }) })
await b.publish({ ...OUT, operation: operation('connect', 'authorizing', { url: 'https://example.com/a', cancellable: true }) })
expect(b.open.mock.calls).toEqual([['https://example.com/a', '_blank', 'noopener,noreferrer']])
b.connection.actions.openAuthorization()
b.connection.page.openAuthorization()
expect(b.open).toHaveBeenCalledTimes(2)
await b.publish({ account: { state: 'in' }, result: { id: OP, kind: 'connect', outcome: 'succeeded' } })
expect(b.snapshot().notice).toEqual({ seq: 1, kind: 'connected' })
expect(b.snapshot().notice).toEqual({ seq: 1, kind: 'succeeded', operation: 'connect' })
await b.publish({ account: { state: 'in' }, result: { id: OP, kind: 'connect', outcome: 'succeeded' } })
expect(b.snapshot().notice?.seq).toBe(1)
b.connection.actions.dismissNotice()
b.connection.dismissNotice()
expect(b.snapshot().notice).toBeUndefined()
})
@@ -134,9 +133,9 @@ it('opens a link reported before the start answered, never a foreign operation,
answer.resolve({ ok: true, value: OP })
await vi.waitFor(() => { expect(b.open).toHaveBeenCalledWith('https://example.com/device', '_blank', 'noopener,noreferrer') })
await b.publish({ ...OUT, operation: operation('connect', 'authorizing', { url: 'http://example.com/device' }) })
b.connection.actions.openAuthorization()
b.connection.page.openAuthorization()
await b.publish({ ...OUT, operation: operation('connect', 'authorizing', { url: 'not a url' }) })
b.connection.actions.openAuthorization()
b.connection.page.openAuthorization()
expect(b.open).toHaveBeenCalledOnce()
})
@@ -162,7 +161,7 @@ it('keeps following its operation when another operation\'s result arrives after
await b.publish({ ...OUT, operation: operation('connect', 'authorizing', { url: 'https://example.com/device' }) })
await b.publish({ account: { state: 'in' }, result: { id: OP, kind: 'connect', outcome: 'succeeded' } })
expect(b.open).toHaveBeenCalledOnce()
expect(b.snapshot().notice).toEqual({ seq: 1, kind: 'connected' })
expect(b.snapshot().notice).toEqual({ seq: 1, kind: 'succeeded', operation: 'connect' })
})
it('follows no operation after a rejected start', async () => {
@@ -181,13 +180,13 @@ it('follows no operation after a rejected start', async () => {
it('cancels only an operation the Host marks cancellable', async () => {
const b = fixture()
b.connection.actions.cancel()
b.connection.page.cancel()
await b.publish({ ...OUT, operation: operation('leave', 'leaving') })
b.connection.actions.cancel()
b.connection.actions.openAuthorization()
b.connection.page.cancel()
b.connection.page.openAuthorization()
expect(b.cancel).not.toHaveBeenCalled()
await b.publish({ ...OUT, operation: operation('connect', 'authorizing', { cancellable: true }) })
b.connection.actions.cancel()
b.connection.page.cancel()
await settle(b)
expect(b.cancel).toHaveBeenCalledWith(OP)
expect(b.open).not.toHaveBeenCalled()
@@ -245,19 +244,19 @@ it('ignores a Host view the stream yields after disposal', async () => {
it('reopens a stopped Host stream on retry and ignores retry while the stream runs', async () => {
const b = fixture()
b.connection.actions.retry()
b.connection.page.retry()
await b.publish(OUT)
expect(b.streams).toHaveLength(1)
b.fail(new Error('gone'))
await vi.waitFor(() => { expect(b.snapshot().stopped).toBe(true) })
b.connection.actions.retry()
b.connection.page.retry()
await vi.waitFor(() => { expect(b.streams).toHaveLength(2) })
expect(b.snapshot()).toMatchObject({ view: undefined, stopped: false })
await b.publish(OUT)
expect(b.snapshot()).toMatchObject({ view: OUT, linked: true })
await b.connection.dispose()
b.connection.actions.retry()
b.connection.page.retry()
expect(b.streams).toHaveLength(2)
})
@@ -266,7 +265,7 @@ it('opens no stream for a retry that disposal overtakes', async () => {
await b.publish(OUT)
b.fail(new Error('gone'))
await vi.waitFor(() => { expect(b.snapshot().stopped).toBe(true) })
b.connection.actions.retry()
b.connection.page.retry()
await b.connection.dispose()
await drain()
expect(b.streams).toHaveLength(1)
@@ -277,8 +276,8 @@ it('reopens one stream for repeated retries and closes that stream on disposal',
await b.publish(OUT)
b.fail(new Error('gone'))
await vi.waitFor(() => { expect(b.snapshot().stopped).toBe(true) })
b.connection.actions.retry()
b.connection.actions.retry()
b.connection.page.retry()
b.connection.page.retry()
await drain()
expect(b.streams).toHaveLength(2)
await b.connection.dispose()
@@ -0,0 +1,105 @@
/** The registry shows an account's four surfaces under the plugin's dictionary and withdraws them with its disposer or this plugin. */
import { Context, Service } from '@deepseek-ai/cordis'
import type { CliAccountView } from '@deepseek-ai/dsh-cli-account/types'
import { LocaleRuntime } from '@deepseek-ai/dsh-client-locale/client'
import { SlotRegistry } from '@deepseek-ai/dsh-client-ui-renderer/client'
import type { RemoteResult } from '@deepseek-ai/dsh-typert-protocol'
import { expect, it, onTestFinished, vi } from 'vitest'
import { CliAccountActivationEntry, CliAccountBadgeEntry, CliAccountSectionEntry, CliAccountToastEntry } from '../src/client/components.tsx'
import { apply, inject } from '../src/client/index.ts'
import type { CliAccountKey, CliAccountRegistration } from '../src/client/types.ts'
import { apply as nodeApply } from '../src/index.ts'
declare module '@deepseek-ai/dsh-client-ui-slots' {
interface LocaleNamespaceMap {
'fixture-account': CliAccountKey | 'notice.connected'
}
}
type View = CliAccountView<{ readonly state: 'out' | 'in' }, 'check' | 'connect', 'authorizing'>
const SLOTS = [
['plugins.bundle.config', CliAccountSectionEntry],
['plugins.bundle.activation', CliAccountActivationEntry],
['plugins.detail.badge', CliAccountBadgeEntry],
['shell.overlay', CliAccountToastEntry],
] as const
function account(packageName: string): CliAccountRegistration<View> {
return {
packageName, locale: 'fixture-account',
follow: () => ({ async *[Symbol.asyncIterator]() { /* the plugin reports nothing in this composition */ } }),
cancel: async (): Promise<RemoteResult<void>> => ({ ok: true, value: undefined }),
notices: { connect: () => 'Connected' },
present: () => ({ phase: 'checking' }),
}
}
async function bench() {
const ctx = new Context()
onTestFinished(async () => { await ctx.fiber.dispose() })
const closed = vi.fn(async () => {})
class Remote extends Service {
constructor() { super(ctx, 'remote') }
$stream() {
return { async *[Symbol.asyncIterator]() { /* the plugin reports nothing in this composition */ }, dispose: closed }
}
}
new Remote()
ctx.provide('locale', new LocaleRuntime(ctx))
await ctx.plugin(SlotRegistry)
ctx.slots.register({ name: 'root', children: {
'plugins.bundle.activation': { kind: 'keyed', scope: 'root' },
'plugins.bundle.config': { kind: 'keyed', scope: 'root' },
'plugins.detail.badge': { kind: 'list', scope: 'root' },
'shell.overlay': { kind: 'list', scope: 'root' },
} } as never, () => null)
const fiber = ctx.plugin({ inject: [...inject], apply })
await fiber
const count = () => SLOTS.reduce((total, [slot]) => total + ctx.slots.entries(slot).length, 0)
return { ctx, fiber, closed, count }
}
it('registers the four surfaces with one shared face and removes them with the disposer', async () => {
const b = await bench()
const registration = account('@acme/fixture')
const dispose = b.ctx.cliAccounts.register(registration)
const faces = SLOTS.map(([slot, component]) => {
const [entry] = b.ctx.slots.entries(slot)
expect(entry).toMatchObject({ locale: 'fixture-account', component })
return entry!.inject!()
})
expect(new Set(faces.map(face => face.hooks)).size).toBe(1)
expect(faces[0]).toMatchObject({ packageName: '@acme/fixture', present: registration.present, notices: registration.notices })
expect(b.ctx.slots.entries('plugins.bundle.config')[0]!.options.key).toBe('@acme/fixture')
expect(b.ctx.slots.entries('plugins.bundle.activation')[0]!.options.key).toBe('@acme/fixture')
expect(b.ctx.slots.entries('plugins.detail.badge')[0]!.options.id).toBe('@acme/fixture.account')
expect(b.ctx.slots.entries('shell.overlay')[0]!.options.id).toBe('@acme/fixture.account-toast')
dispose()
await vi.waitFor(() => { expect(b.closed).toHaveBeenCalledOnce() })
expect(b.count()).toBe(0)
dispose()
expect(b.closed).toHaveBeenCalledOnce()
})
it('withdraws every account when this plugin unloads', async () => {
const b = await bench()
b.ctx.cliAccounts.register(account('@acme/fixture'))
b.ctx.cliAccounts.register(account('@acme/other'))
expect(b.count()).toBe(8)
await b.fiber.dispose()
expect(b.count()).toBe(0)
expect(b.closed).toHaveBeenCalledTimes(2)
})
it('rolls back a registration whose package another account already shows', async () => {
const b = await bench()
b.ctx.cliAccounts.register(account('@acme/fixture'))
expect(() => b.ctx.cliAccounts.register(account('@acme/fixture'))).toThrow()
await vi.waitFor(() => { expect(b.closed).toHaveBeenCalledOnce() })
expect(b.count()).toBe(4)
})
it('keeps the Node half inert', () => {
expect(() => { nodeApply() }).not.toThrow()
})
@@ -14,15 +14,27 @@
{
"path": "../../api/gateway/tsconfig.client.json"
},
{
"path": "../../api/remotes/tsconfig.client.json"
},
{
"path": "../../connector/cli-account"
},
{
"path": "../store"
},
{
"path": "../ui-layout"
},
{
"path": "../ui-plugin-manager/tsconfig.client.json"
},
{
"path": "../ui-primitives"
},
{
"path": "../ui-renderer"
},
{
"path": "../ui-slots"
},
@@ -1,6 +1,3 @@
import { staticLinked } from '../tsdown.client.ts'
import { clientBundle } from '../tsdown.client.ts'
export default staticLinked(
import.meta.dirname,
['lib/types/index.js'],
)
export default clientBundle(import.meta.dirname, ['lib/types/index.js'])
-1
View File
@@ -31,7 +31,6 @@
"@deepseek-ai/dsh-client-modules": "workspace:*",
"@deepseek-ai/dsh-client-store": "workspace:*",
"@deepseek-ai/dsh-client-ui-dockkit": "workspace:*",
"@deepseek-ai/dsh-client-ui-cli-account": "workspace:*",
"@deepseek-ai/dsh-client-ui-renderer": "workspace:*",
"@deepseek-ai/dsh-client-ui-primitives": "workspace:*",
"@deepseek-ai/dsh-client-ui-slots": "workspace:*",
-1
View File
@@ -12,7 +12,6 @@ export const PLATFORM_MODULES = [
'@deepseek-ai/dsh-client-ui-slots',
'@deepseek-ai/dsh-client-ui-primitives',
'@deepseek-ai/dsh-client-ui-dockkit',
'@deepseek-ai/dsh-client-ui-cli-account',
] as const
/** Client-bundle specifiers whose factories the parser preloads before the shell starts. */
-2
View File
@@ -17,7 +17,6 @@ import * as ClientStore from '@deepseek-ai/dsh-client-store'
import * as UiSlots from '@deepseek-ai/dsh-client-ui-slots'
import * as UiPrimitives from '@deepseek-ai/dsh-client-ui-primitives'
import * as UiDockkit from '@deepseek-ai/dsh-client-ui-dockkit'
import * as UiCliAccount from '@deepseek-ai/dsh-client-ui-cli-account'
import type { PlatformModule } from './platform.ts'
/**
@@ -40,6 +39,5 @@ export function getStaticModules(): Record<string, unknown> {
'@deepseek-ai/dsh-client-ui-slots': UiSlots,
'@deepseek-ai/dsh-client-ui-primitives': UiPrimitives,
'@deepseek-ai/dsh-client-ui-dockkit': UiDockkit,
'@deepseek-ai/dsh-client-ui-cli-account': UiCliAccount,
} satisfies Record<PlatformModule, unknown>
}
-3
View File
@@ -29,9 +29,6 @@
{
"path": "../ui-dockkit"
},
{
"path": "../ui-cli-account"
},
{
"path": "../ui-renderer"
},
+2 -2
View File
@@ -18,8 +18,8 @@
en: 3e7e372d19a64dc6
zh: 7c3baffa308965bc
/connector-application-plugins/related-documentation:
en: 434311433c42db3c
zh: 2a01ec7ac137cfe3
en: 300b6c13c036c818
zh: fc6307f506d922dc
/connector-application-plugins/dev-note:
en: 5de1d6304e00c58f
zh: 3fee785f424f1018
+1 -1
View File
@@ -35,7 +35,7 @@ Each application plugin in this group is installed into a profile to use one thi
- [Skill subsystem reference](../../docs/subsystems/skills.md) — the registry and provider contract that connector skills use.
- [System prompt](../core/system-prompt/README.md) — the registry that orders and renders runtime context.
- [CLI plugin page pieces](../client/ui-cli-account/README.md) — the Plugins page half of the CLI account library.
- [CLI account surfaces](../client/ui-cli-account/README.md) — the Plugins page registry where CLI app plugins show their accounts.
-----
+1 -1
View File
@@ -35,7 +35,7 @@ kind: "package-group"
- [Skill 子系统参考](../../docs/subsystems/skills.zh.md)——connector skill 使用的注册表与提供方契约。
- [System prompt](../core/system-prompt/README.zh.md)——排序并渲染运行时上下文的注册表。
- [CLI 插件页组件](../client/ui-cli-account/README.zh.md)——CLI 账号库在插件页的一半。
- [CLI 账号界面](../client/ui-cli-account/README.zh.md)——CLI 应用插件在插件页显示账号的注册表。
-----
@@ -36,8 +36,8 @@
en: 70dc4b7f754dc41c
zh: 9abbad7269501038
/deepseek-ai-dsh-cli-account/further-exploration:
en: ec156b5debabecb0
zh: 660d86db8f5658db
en: f14825452ee439c5
zh: 2a6a43122f9676d1
/deepseek-ai-dsh-cli-account/model-experience:
en: 215e7ba838619b7b
zh: a311da3843709f90
+1 -1
View File
@@ -106,7 +106,7 @@ The runtime owns the operation lifecycle and the plugin owns the meaning of each
## Further Exploration
- [Connector packages](../README.md) — the group this library and the CLI app plugins belong to.
- [CLI plugin page pieces](../../client/ui-cli-account/README.md) — the browser half that mirrors the view.
- [CLI account surfaces](../../client/ui-cli-account/README.md) — the Plugins page registry that mirrors the view.
- [System prompt](../../core/system-prompt/README.md) — the registry that orders and renders runtime context.
- [Subprocess](../../subprocess/subprocess/README.md) — the runtime that resolves and spawns the CLI.
+1 -1
View File
@@ -106,7 +106,7 @@ const account = new Account({
## 延伸阅读
- [Connector 包](../README.zh.md)——这个库和 CLI 应用插件所属的分组。
- [CLI 插件页组件](../../client/ui-cli-account/README.zh.md)——镜像视图的浏览器一半。
- [CLI 账号界面](../../client/ui-cli-account/README.zh.md)——镜像这个视图的插件页注册表。
- [System prompt](../../core/system-prompt/README.zh.md)——排序并渲染运行时上下文的注册表。
- [Subprocess](../../subprocess/subprocess/README.zh.md)——查找并启动 CLI 的运行时。
@@ -2586,7 +2586,7 @@ export const CLIENT_SLOT_API: readonly ClientSlotEntry[] = [
slotInject: '',
declaredBy: 'an entry in \'main\' (client-ui-plugin-manager), so it exists while that entry is mounted',
occupants: [
'client-ui-feishu FeishuConnectionActivation',
'client-ui-cli-account CliAccountActivationEntry',
'experimental-client-ui-voice-input VoiceSetupPrompt key \'@deepseek-ai/dsh-experimental-voice-input-bundle\'',
'cua PermissionSetup key \'@deepseek-ai/dsh-cua-bundle\'',
],
@@ -2631,7 +2631,7 @@ export const CLIENT_SLOT_API: readonly ClientSlotEntry[] = [
slotInject: '',
declaredBy: 'an entry in \'main\' (client-ui-plugin-manager), so it exists while that entry is mounted',
occupants: [
'client-ui-feishu FeishuConnectionSection',
'client-ui-cli-account CliAccountSectionEntry',
'experimental-client-ui-cot-translation TranslationSettings key \'@deepseek-ai/dsh-experimental-cot-translation-bundle\'',
'experimental-client-ui-voice-input VoicePreparation key \'@deepseek-ai/dsh-experimental-voice-input-bundle\'',
'cua PermissionPanel key \'@deepseek-ai/dsh-cua-bundle\'',
@@ -2742,7 +2742,7 @@ export const CLIENT_SLOT_API: readonly ClientSlotEntry[] = [
slotInject: '',
declaredBy: 'an entry in \'main\' (client-ui-plugin-manager), so it exists while that entry is mounted',
occupants: [
'client-ui-feishu FeishuConnectionBadge id \'feishu.connection\'',
'client-ui-cli-account CliAccountBadgeEntry',
],
replaceRisk: 'none',
example: 'return {\n inject: [\'slots\'],\n apply(ctx) {\n ctx.slots.inject(\'plugins.detail.badge\', () => ctx.slots.register(\n { name: \'plugins.detail.badge\', id: \'my-entry\', order: 100, label: \'My entry\' },\n () => React.createElement(\'div\', null, \'hello\'),\n ))\n },\n}',
@@ -3720,8 +3720,8 @@ export const CLIENT_SLOT_API: readonly ClientSlotEntry[] = [
declaredBy: 'an entry in \'root\' (client-ui-layout), so it exists while that entry is mounted',
occupants: [
'client-ui-chat QuotaNoticeHost id \'chat.quota-notice\'',
'client-ui-cli-account CliAccountToastEntry',
'client-ui-context-menu MenuOverlay id \'context-menu\'',
'client-ui-feishu FeishuConnectionToast id \'feishu.connection-toast\'',
'client-ui-file-drag FileDragFeedback id \'file-drag.feedback\'',
'client-ui-open-in-app OpenInAppToast id \'open-in-app.toast\'',
'client-ui-plugin-manager PluginRefreshToast id \'plugin-manager.refresh-toast\'',
@@ -72,6 +72,7 @@ Every package below exports a Cordis plugin that a bundle patch can name in a Lo
| `@deepseek-ai/dsh-client-ui-attachment` | no | Dynamic attachment presentation plugin for conversation input, message-image, and trajectory image slots |
| `@deepseek-ai/dsh-client-ui-brand-official` | no | Official DeepSeek Harness brand occupants for the Web client's sidebar slots |
| `@deepseek-ai/dsh-client-ui-chat` | no | Chat Conversation target, node definitions, renderers, and details surface |
| `@deepseek-ai/dsh-client-ui-cli-account` | no | CLI account surfaces for CLI app plugins: the account section, title tag, activation prompt, and notices on the Plugins page, over each plugin's account Remote |
| `@deepseek-ai/dsh-client-ui-commands` | no | Client command surface: global directory cache, '/' source, three command UI kinds, popupSelect registry |
| `@deepseek-ai/dsh-client-ui-context-menu` | no | Typed, plugin-extensible context menus with captured targets and shared Web presentation |
| `@deepseek-ai/dsh-client-ui-conversation` | no | Target-neutral Conversation assembly, shell, composer, queue, and view navigation |
+18 -6
View File
@@ -986,9 +986,6 @@ importers:
'@deepseek-ai/dsh-client-test-runtime':
specifier: workspace:*
version: link:../../packages/test-support/client-runtime
'@deepseek-ai/dsh-client-ui-cli-account':
specifier: workspace:*
version: link:../../packages/client/ui-cli-account
'@deepseek-ai/dsh-client-ui-deliverables':
specifier: workspace:*
version: link:../../packages/client/ui-deliverables
@@ -3011,6 +3008,9 @@ importers:
'@deepseek-ai/dsh-client-ui-chat':
specifier: workspace:*
version: link:../../client/ui-chat
'@deepseek-ai/dsh-client-ui-cli-account':
specifier: workspace:*
version: link:../../client/ui-cli-account
'@deepseek-ai/dsh-client-ui-commands':
specifier: workspace:*
version: link:../../client/ui-commands
@@ -3994,18 +3994,33 @@ importers:
'@deepseek-ai/dsh-api-gateway':
specifier: workspace:*
version: link:../../api/gateway
'@deepseek-ai/dsh-api-remotes':
specifier: workspace:*
version: link:../../api/remotes
'@deepseek-ai/dsh-cli-account':
specifier: workspace:*
version: link:../../connector/cli-account
'@deepseek-ai/dsh-client-locale':
specifier: workspace:*
version: link:../locale
'@deepseek-ai/dsh-client-store':
specifier: workspace:*
version: link:../store
'@deepseek-ai/dsh-client-test-runtime':
specifier: workspace:*
version: link:../../test-support/client-runtime
'@deepseek-ai/dsh-client-ui-layout':
specifier: workspace:*
version: link:../ui-layout
'@deepseek-ai/dsh-client-ui-plugin-manager':
specifier: workspace:*
version: link:../ui-plugin-manager
'@deepseek-ai/dsh-client-ui-primitives':
specifier: workspace:*
version: link:../ui-primitives
'@deepseek-ai/dsh-client-ui-renderer':
specifier: workspace:*
version: link:../ui-renderer
'@deepseek-ai/dsh-client-ui-slots':
specifier: workspace:*
version: link:../ui-slots
@@ -7214,9 +7229,6 @@ importers:
'@deepseek-ai/dsh-client-store':
specifier: workspace:*
version: link:../store
'@deepseek-ai/dsh-client-ui-cli-account':
specifier: workspace:*
version: link:../ui-cli-account
'@deepseek-ai/dsh-client-ui-dockkit':
specifier: workspace:*
version: link:../ui-dockkit
-1
View File
@@ -212,7 +212,6 @@ const packageFileExtras: Readonly<Record<string, readonly string[]>> = {
// unpublished, as everywhere else in the repository.
'@deepseek-ai/dsh-client-ui-primitives': ['lib/**/*.css'],
'@deepseek-ai/dsh-client-ui-dockkit': ['lib/**/*.css'],
'@deepseek-ai/dsh-client-ui-cli-account': ['lib/**/*.css'],
'@deepseek-ai/dsh-client-ui-sidebar-documentpreview': ['lib/client.*.js'],
'@deepseek-ai/dsh-client-ui-sidebar-terminal': ['lib/client.*.js'],
'@deepseek-ai/dsh-client-web': ['lib/**/*.css', 'lib/apply-injections.js'],
-1
View File
@@ -63,7 +63,6 @@ const PACKAGE_LIBRARIES: Readonly<Record<string, string>> = {
'packages/connector/cli-account': 'Host library CLI app plugins import for commands, account operations, and the CLI path context; plain class and function exports.',
'packages/client/store': 'Browser-side state primitives; plain function/type exports.',
'packages/client/ui-primitives': 'Browser-side UI component library; plain component exports.',
'packages/client/ui-cli-account': 'Browser-side Plugins page library for CLI app plugins; plain component and class exports.',
'packages/client/ui-slots': 'Browser-side slot-map declarations; plain type exports.',
'packages/client/web': 'Browser application boot library; exports the app entry and static module table.',
'packages/core/scope': 'Scoped-context primitives; exports functions and types without a plugin entry.',
+1
View File
@@ -205,6 +205,7 @@ export const SERVICE_WALK_EXEMPTIONS: Record<string, string> = {
commandUi: 'client-side interface-typed browser service — packages/client/ui-commands/README.md owns the API',
fileDrag: 'client-side file preparation and transfer service — packages/client/ui-file-drag/README.md owns the API',
feedbackUi: 'client-side feedback dialog service — packages/client/ui-message-feedback/README.md owns the API',
cliAccounts: 'client-side CLI app account registry — packages/client/ui-cli-account/README.md owns the API',
conversation: 'client-side interface-typed browser service — packages/client/ui-conversation/README.md owns the API',
layout: 'client-side interface-typed browser service — packages/client/ui-layout/README.md owns the API',
pluginNavigation: 'client-side bundle navigation — packages/client/ui-plugin-manager/README.md owns the API',
@@ -161,7 +161,7 @@ const SENTENCE_MODEL_EXPERIENCE: Readonly<Record<string, SentenceContract>> = {
'packages/extensions/ui-cordis': { kind: 'indirect', reason: 'The definition card drives the host dynamic run/stop verbs that the model\'s cordis_run/cordis_stop tools also reach; the runner owns any model-visible effect.' },
'packages/client/ui-permission-presets': { kind: 'indirect', reason: 'The picker submits the host /permission command; the knob events it appends own the model-visible effect through the sandbox/approval consumers.' },
'packages/client/ui-settings-plugins': { kind: 'none', reason: 'Browser-side settings surface; registers no model surface.' },
'packages/client/ui-cli-account': { kind: 'none', reason: 'Browser-side Plugins page pieces; registers no model surface.' },
'packages/client/ui-cli-account': { kind: 'none', reason: 'Browser-side account controls over CLI app plugin Remotes; each plugin documents the CLI and skills its account enables.' },
'packages/client/ui-settings-shell': { kind: 'none', reason: 'Browser-side settings surface; registers no model surface.' },
'packages/client/ui-feishu': { kind: 'none', reason: 'Browser-side Plugins page section; registers no model surface.' },
'packages/client/ui-settings-session-log': { kind: 'none', reason: 'Browser preference controls request metadata, not model input.' },