@dsh-workbench/core 0.2.12 → 0.2.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (27) hide show
  1. package/client.js +418 -114
  2. package/dist/client/client.body.js +418 -114
  3. package/dist/client/index.js +418 -114
  4. package/dist/host/index.js +78 -78
  5. package/dist/types/app/client.d.ts +87 -15
  6. package/dist/types/app/layouts/__tests__/kit-preview-nav.test.d.ts +1 -0
  7. package/dist/types/app/layouts/rightbar/kit-preview-controls.d.ts +1 -0
  8. package/dist/types/app/layouts/rightbar/kit-preview-frame.d.ts +4 -0
  9. package/dist/types/app/layouts/rightbar/kit-preview-hash.d.ts +1 -0
  10. package/dist/types/app/layouts/rightbar/kit-preview-rows.d.ts +1 -0
  11. package/dist/types/app/layouts/sidebar/ProjectSwitcher.d.ts +3 -1
  12. package/dist/types/app/layouts/sidebar/SidebarHeader.d.ts +12 -0
  13. package/dist/types/app/layouts/sidebar/WorkspaceAttentionDot.d.ts +9 -0
  14. package/dist/types/app/layouts/sidebar/WorkspaceAttentionTag.d.ts +7 -0
  15. package/dist/types/app/layouts/sidebar/__tests__/current-workspace.test.d.ts +1 -0
  16. package/dist/types/app/layouts/sidebar/current-workspace.d.ts +8 -0
  17. package/dist/types/app/layouts/sidebar/use-attention.d.ts +16 -0
  18. package/dist/types/app/layouts/sidebar/workspace-items.d.ts +2 -0
  19. package/dist/types/modules/sessions/index.d.ts +1 -0
  20. package/dist/types/modules/sessions/model/attention.d.ts +22 -0
  21. package/dist/types/modules/sessions/model/attention.test.d.ts +1 -0
  22. package/package.json +2 -2
  23. package/skills/workbench-module-diy/BUILD.md +1 -1
  24. package/skills/workbench-module-diy/DATASOURCE.md +1 -1
  25. package/skills/workbench-module-diy/KIT.md +57 -5
  26. package/skills/workbench-module-diy/PANEL.md +1 -1
  27. package/skills/workbench-module-diy/REVIEW.md +2 -2
@@ -0,0 +1,16 @@
1
+ import type { SessionStatusSnapshot, SessionsSnapshot, WorkspaceView } from '@dsh-workbench/shared';
2
+ import { type Attention } from '../../../modules/sessions';
3
+ export interface SidebarAttentionInput {
4
+ readonly items: readonly WorkspaceView[];
5
+ readonly sessions: SessionsSnapshot;
6
+ readonly statusById: SessionStatusSnapshot;
7
+ readonly archived: readonly string[];
8
+ readonly storedId: string | null;
9
+ readonly panelActive: boolean;
10
+ }
11
+ export interface SidebarAttentionState {
12
+ readonly current: WorkspaceView | null;
13
+ readonly archivedIds: ReadonlySet<string>;
14
+ readonly attention: Attention;
15
+ }
16
+ export declare function useSidebarAttention(input: SidebarAttentionInput): SidebarAttentionState;
@@ -1,10 +1,12 @@
1
1
  import type { SelectFieldOption, Translate, WorkspaceView } from '@dsh-workbench/shared';
2
+ import type { WorkspaceAttention } from '../../../modules/sessions';
2
3
  import type { WorkspaceSectionPlan } from './workspace-groups';
3
4
  export interface WorkspaceItemsOptions {
4
5
  readonly sections: readonly WorkspaceSectionPlan<WorkspaceView>[];
5
6
  readonly currentId: string | null;
6
7
  readonly hoverId: string | null;
7
8
  readonly t: Translate;
9
+ readonly attention: ReadonlyMap<string, WorkspaceAttention>;
8
10
  readonly onHover: (workspaceId: string | null) => void;
9
11
  readonly onEdit: (workspace: WorkspaceView) => void;
10
12
  }
@@ -1,2 +1,3 @@
1
1
  export { currentSessionId, orderByRecency, sessionNode, orderSessionRows, sessionRows, workspaceOfSession, sessionStatuses, visiblePendingKind, type SessionNode, type SessionStatusDot, } from './model/session-node';
2
2
  export { scrollEdgesOf, type ScrollEdges } from './model/scroll-edges';
3
+ export { attentionLabel, attentionOf, attentionOfSession, attentionWordLabel, type Attention, type AttentionInput, type AttentionSeverity, type WorkspaceAttention, } from './model/attention';
@@ -0,0 +1,22 @@
1
+ import type { SessionStatusSnapshot, SessionSummary, SessionsSnapshot, Translate, WorkspaceView } from '@dsh-workbench/shared';
2
+ export type AttentionSeverity = 'warning' | 'ongoing' | 'done';
3
+ export interface WorkspaceAttention {
4
+ readonly severity: AttentionSeverity;
5
+ readonly count: number;
6
+ }
7
+ export interface Attention {
8
+ readonly byWorkspace: ReadonlyMap<string, WorkspaceAttention>;
9
+ readonly elsewhere: WorkspaceAttention | null;
10
+ readonly overall: WorkspaceAttention | null;
11
+ }
12
+ export interface AttentionInput {
13
+ readonly workspaces: readonly WorkspaceView[];
14
+ readonly sessions: SessionsSnapshot;
15
+ readonly statusById: SessionStatusSnapshot;
16
+ readonly archivedIds: ReadonlySet<string>;
17
+ readonly currentWorkspaceId: string | null;
18
+ }
19
+ export declare function attentionOfSession(summary: SessionSummary, statusById: SessionStatusSnapshot, sessions: SessionsSnapshot): AttentionSeverity | undefined;
20
+ export declare function attentionOf(input: AttentionInput): Attention;
21
+ export declare function attentionLabel(attention: WorkspaceAttention, t: Translate): string;
22
+ export declare function attentionWordLabel(attention: WorkspaceAttention, t: Translate): string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dsh-workbench/core",
3
- "version": "0.2.12",
3
+ "version": "0.2.14",
4
4
  "description": "个人工作台:Agent 工作台外壳(左栏 + 常驻对话 + 自研右侧数据面板)。",
5
5
  "type": "module",
6
6
  "icon": "./icon.svg",
@@ -87,7 +87,7 @@
87
87
  "access": "public"
88
88
  },
89
89
  "dependencies": {
90
- "@dsh-workbench/shared": "0.2.12"
90
+ "@dsh-workbench/shared": "0.2.14"
91
91
  },
92
92
  "scripts": {
93
93
  "build": "node scripts/build.mjs && node scripts/build-types.mjs",
@@ -145,6 +145,6 @@ export function apply(ctx) {
145
145
  "空"和"还没开始"是两件事,说错了他会去查他根本没配的东西。
146
146
 
147
147
  **卡片必须在拿不到数据时也画得出来**(第一次读、卡在审批、平台没登录)。
148
- 空数据下抛异常的卡片 = 用户眼里的"卡片一直不出来"。这是 `check:cards` 守的那条。
148
+ 任何一种输入(待机 / 在读 / 有值 / 有值但空 / 读不到)下抛异常、屏上冒出 `undefined` / `NaN` 的卡片 = 用户眼里的"卡片一直不出来"。这是 `check:cards` 守的那条。
149
149
 
150
150
  → 拿到依赖、装上、改一行、发出去:[WIRING.md](WIRING.md)。
@@ -97,7 +97,7 @@
97
97
  | 超时 / 网络不通 | "这次没读到,稍后重试" + 重试 |
98
98
  | 站点改版、字段没了 | "读到的形状和预期不一样"(别显示空白,也别显示 0) |
99
99
 
100
- 空数据下抛异常的卡片 = 用户眼里的"卡片一直不出来"。这条 `check:cards` 会拦(见 [REVIEW.md](REVIEW.md))。
100
+ 任何一种输入(待机 / 在读 / 有值 / 有值但空 / 读不到)下抛异常、屏上冒出 `undefined` / `NaN` 的卡片 = 用户眼里的"卡片一直不出来"。这条 `check:cards` 会拦(见 [REVIEW.md](REVIEW.md))。
101
101
 
102
102
  ## 错误码不是随便写的(阻断屏按它换文案)
103
103
 
@@ -82,7 +82,7 @@ h(Field, { label: t('myunit.mode'), hint: t('myunit.modeHint') },
82
82
  ```
83
83
 
84
84
  **`TextField`** —— 单行输入(`invalid` 标红;其余是原生 input 的 props)。
85
- **`ChoiceGroup`** —— 单选 / 多选(`multi` 区分;`value` 或 `values` + `onChange`;选项 `{ value, label, hint?, disabled? }`)。
85
+ **`ChoiceGroup`** —— 单选 / 多选(`multi` 区分;`value` 或 `values` + `onChange`;选项 `{ value, label, description? }`;`disabled` 在整组上)。
86
86
  **`SelectField`** —— 下拉:默认是**常规下拉框**(跟 `TextField` 一套),无边框那种给 `variant: 'ghost'`;
87
87
  搜索、分组、禁用项、加载态、空态、页脚都是它的 prop。
88
88
  **`SaveBar`** —— 设置面底下那条"取消 / 保存"(`busy` / `disabled` / `labels` / `onCancel` / `onSave`)。
@@ -91,7 +91,59 @@ h(Field, { label: t('myunit.mode'), hint: t('myunit.modeHint') },
91
91
  kit 有上面这几件;手写的会拿到浏览器默认样式,而且**判据会红**(`check:style`)。
92
92
  `<textarea>` 例外(dsh 与 kit 都没有多行输入)——真要用就直接写,其余形态别开这个口子。
93
93
 
94
- ## 5 别的
94
+ 控件怎么排成一行(标签位置、错误态、尺寸)见 §5。
95
+
96
+ ## 5 表单这一层:面 → 行 → 控件
97
+
98
+ 表单三层:**面**(`SettingsSection` / `SaveBar`)→ **行**(`FormRows` + `FormRow`)→
99
+ **控件**(`TextField` / `SelectField` / `ChoiceGroup`)。**一行一个字段**,行这一层只有一个出处。
100
+
101
+ ```tsx
102
+ h(FormRows, null,
103
+ h(FormRow, { label: t('myunit.mode'), hint: t('myunit.modeHint') },
104
+ h(SelectField, { value, options, onChange: setMode })),
105
+ h(FormRow, { label: t('myunit.env'), problem: problemOfEnv },
106
+ h(ChoiceGroup, { label: t('myunit.env'), name: 'env', options, value: env, onChange: setEnv })))
107
+ ```
108
+
109
+ - **标签归 `FormRow`**(`label`):默认标签在左,`layout: 'stacked'` 才是上下堆叠(等于原来的 `Field`)。
110
+ **控件只给数据与语义 prop**,不写外观类名(§7 第 1 条)。进了 `FormRow` 就别再给控件自己的
111
+ `label` / `hint`(`SelectField` 那两件是没 `FormRow` 时的兜底,重复给会多一个标签、还退回上下堆叠)。
112
+ - **`hint` 与 `problem` 二选一**:给了 `problem` 就不画 `hint` —— 同一格不叠两段话,有错先显示错。
113
+
114
+ **错误态**:位置与长相由 `FormRow.problem` + 控件的 `invalid` 定(`SelectField` / `TextField` 同形,
115
+ `ChoiceGroup` 见它自己的档)。**校验逻辑留在模块**:只写"算错误"的纯函数与文案
116
+ (例:cmdb 的 `CmdbFormProblem` 那类),**别指望外壳给校验引擎**(不做 `rules` / `validate`、
117
+ 不做联动、不持有值)。提交失败后调 `kit.lib.revealFirstProblem(root)`(`root` = 表单容器)——
118
+ 把第一处错误带进视口、并聚焦它里面的控件。
119
+
120
+ **选择类用哪件**:候选多 / 要搜索 / 要分组 / 名单可能读不到 ⇒ `SelectField`(`search` 默认开、
121
+ `emptyText`、`loading` + `loadingText`、`fallback`、`variant: 'boxed' | 'ghost'`);
122
+ 候选少、要一眼看全 / 多选 ⇒ `ChoiceGroup`(`multi`、`variant`、`loading` + `loadingText`、
123
+ `emptyText`、`options[].description`)。两件的 `loading` / `loadingText` / `emptyText` / `variant`
124
+ 是一个意思;**loading 那颗一律是 `Spinner`**(`h(Spinner, { size: 14 })`)—— **别自己写转圈**。
125
+
126
+ **尺寸口径**:字段控件默认 **28**(dsh 紧凑档),**别自己调高**;行距**只有一档**、归 `FormRow(s)`,
127
+ 模块里不该出现管行距的 `gap` / `margin`(横向的、卡片/清单网格的不算)。标签列也归它:
128
+ **长标签不折行;同一 `FormRows` 共用一个标签列(列宽由最长的标签定),别自己给标签写宽度**
129
+ (非行的子项,比如分组标题 `<p>`,自动通栏)。
130
+
131
+ **反例(别这么写)**:
132
+
133
+ ```tsx
134
+ h('span', { className: styles.label }, t('myunit.mode')) // ← 紧邻控件的手写标签行:check:style 红
135
+ h('div', { className: styles.form }, …) // ← .form { gap: 8px }:自己管行距也红
136
+ ```
137
+
138
+ `<span className={styles.label}>` 紧邻控件、或给表单容器自己写 `gap` —— 这正是 `check:style` 那条
139
+ 棘轮(F1 手写行 / F2 自己管行距)盯的东西;`FORM_ROW_EXEMPT` 是**等外壳发版后要清空的历史账**
140
+ ("迁一处删一行"),**不是"可以继续这么写"的许可**。
141
+
142
+ **时点**:这一层随外壳**发版**后模块才能用 —— 模块的 `peerDependencies` 下限得先有它
143
+ (`check:kit` 拿 peer 下限那份外壳比,不抬必红);迁移步骤见
144
+ [ADR-0052](../../../../docs/adr/0052-the-form-row-is-one-component.md) §10。
145
+
146
+ ## 6 别的
95
147
 
96
148
  - **`Link`** —— **唯一**的外链写法:`h(Link, { href, children })`。自带新窗口 + `rel="noopener noreferrer"`
97
149
  + 正文色 + hover 下划线 + 那颗小箭头。**别去掉箭头、别在文案里自带 `→`、别手写 `<a>`**(判据红)。
@@ -99,11 +151,11 @@ kit 有上面这几件;手写的会拿到浏览器默认样式,而且**判
99
151
  - **`Stack`** —— 竖排 + 统一间距(懒得分组时的默认容器)。
100
152
  - **`BlockerState`** —— 阻断屏:要登录 / 没权限 / 能力没装好那一类(`blocker` / `t` / `onRetry` / `onOpenMarket`)。
101
153
  - **`Tip`** —— Tooltip:图标钮与只有图的地方**必须**有它(或 `aria-label`)。
102
- - **别给模块带夹具**:2026-10-16 起模板 / `init` 文案 / 这份指引都不带评审夹具了(`?wbMock=1` 那套、`useFixturePick` / `MockStrip` / `mockNote` 都从模板里删了)。夹具是模块作者负担里最不值的那一份 —— 而**你自己那份 `plugin.test.ts` 就能把五态各喂一遍**,门禁从来只问"空数据画不画得出"(`check:cards`)。外壳自己那套 `?wbMock=1` 夹具是给**外壳的卡片**用的,模块不必跟(机制仍在,谁想要仍然可以用,但**不是你要做的事**)。
154
+ - **别给模块带夹具**:2026-10-16 起模板 / `init` 文案 / 这份指引都不带评审夹具了(`?wbMock=1` 那套、`useFixturePick` / `MockStrip` / `mockNote` 都从模板里删了)。夹具是模块作者负担里最不值的那一份 —— 而**你自己那份 `plugin.test.ts` 就能把五态各喂一遍**,而 `check:cards` 会拿七种外壳侧输入各喂一遍(它只问"退化得干不干净",不断言"画的是哪一态那一屏")。外壳自己那套 `?wbMock=1` 夹具是给**外壳的卡片**用的,模块不必跟(机制仍在,谁想要仍然可以用,但**不是你要做的事**)。
103
155
  - **图标** —— `IconPanelScreen`(面板/卡片那类)、`IconModuleMark`(我们的模块类型标)、
104
156
  `IconNpm` / `IconOpencli`(包类型);其余图形一律从 dsh 的 `Icon*Regular` 拿,**别自己画图标**。
105
157
 
106
- ## 6 三条纪律
158
+ ## 7 三条纪律
107
159
 
108
160
  1. **调用点只给数据与语义**:`h(Card, { title, refreshing, onRefresh }, …)`。别从外面塞外观类名
109
161
  —— 只有布局槽例外(通栏、外边距、网格位置)。
@@ -114,7 +166,7 @@ kit 有上面这几件;手写的会拿到浏览器默认样式,而且**判
114
166
  3. **自己写 CSS 只写布局**(flex / grid / gap / 对齐)。要一个新的"长得像控件"的东西时,
115
167
  先问一句:kit 里是不是已经有了?
116
168
 
117
- ## 7 kit 里没有、但你确定要标准控件
169
+ ## 8 kit 里没有、但你确定要标准控件
118
170
 
119
171
  见 [PANEL.md](PANEL.md) §9:可以引 dsh 的客户端原语,但**只在浏览器侧**、并在
120
172
  `package.json` 的 `dsh.client.external` 里声明 `@deepseek-ai/dsh-client-ui-primitives`
@@ -164,7 +164,7 @@ agent 那一侧也要能通过模块自己的能力读到同一份偏好。
164
164
  - **平台没给的那一格就不占位**(不留孤零零的字段名、不留空的一行)。
165
165
  - **读不到就说读不到**,并说清为什么(例:手上这份能力太旧);**绝不显示 0**。
166
166
  - 有确定答案就不打扰他(能按默认读出来就别弹设置面)。
167
- - 真机上造不出来的状态也要**在设计上**画出来(照这一格写清)—— 但**不必为它写夹具**:2026-10-16 起模板与指引都不带评审夹具,模块自己的 `plugin.test.ts` 把五态各喂一遍就够(门禁只问"空数据画不画得出")。
167
+ - 真机上造不出来的状态也要**在设计上**画出来(照这一格写清)—— 但**不必为它写夹具**:2026-10-16 起模板与指引都不带评审夹具,模块自己的 `plugin.test.ts` 把五态各喂一遍就够(`check:cards` 会拿**七种外壳侧输入**各喂一遍 —— 它只问"退化得干不干净",**不断言**"画的是哪一态那一屏")。
168
168
 
169
169
  ### 7.1 图例就是把屏幕画成 ASCII
170
170
 
@@ -11,11 +11,11 @@
11
11
  | `source` | 非种子词的 `@deepseek-ai/*`、宿主侧碰 dsh 的浏览器包、`@/` 指到工作台源码 | `…在宿主侧可达` / `不是平台种子词` | 宿主侧只用 Node 侧的东西;dsh 原语一律走 `kit`;`@/` 只指自己的 `src/` |
12
12
  | `primitives` | 声明了 `external` 却没有产物物证 ⇒ dsh 原语被**内联**成第二份实例 | `…用了却没声明 external` / `宿主产物里出现了` | 在 `dsh.client.external` 里显式声明它;确认产物里是 `require(...)` 而不是被打包进来 |
13
13
  | `kit` | 用了 peer 下限那份外壳**还没有**的 kit 成员 ⇒ 卡片首帧 `Element type is invalid`,整块面板被 React 卸掉 | `kit.components.X 在这份外壳里没有` / `peer 下限比 devDependency 还旧` | 只用 peer 范围里真有的成员;把 `peerDependencies` 的下限提到你实际用的那档 |
14
- | `cards` | 卡片拿**空数据**就抛 ⇒ 用户看到"卡片一直不出来 / 点一下白屏" | `空数据下卡片抛了` / `卡片只画出一个节点` / `卡片没套外壳的卡壳` / `清单的 card.titleKey「x」在模块字典的 en 里没有` / `…没有落点` | 让卡片在没数据时也画得出来(已有的加载 / 空 / 阻断态);外面套 `kit.components.Card`;清单写了 `titleKey`,`registerUnit` 交的 `messages` 里 `zh` / `en` 都得有那一条(漏了面板上显示的是原始键名) |
14
+ | `cards` | 卡片在某一种**外壳侧输入**下崩 / 空白 / 变脏 ⇒ 用户看到"卡片一直不出来 / 点一下白屏 / 屏上冒出 `undefined`"。判据拿七种输入各喂一遍(待机 / 在读 / 在读但保留旧值 / 有值 / 有值但空容器 / 读不到 / 能力闸缺插件),`zh`、`en` 各一遍;取数走**你装的那份真壳**的 `useUnitBoard` | `loading(zh) 卡片抛了` / `loading(zh) 卡片返回空` / `屏上出现了 undefined`(`NaN` / `[object Object]` / `null` 同形) / `t('x') 在 zh 里没有落点` / `卡片没套外壳的卡壳` / `清单的 card.titleKey「x」在模块字典的 en 里没有` | 让卡片在五态下都画得出来(已有的加载 / 空 / 阻断态);外面套 `kit.components.Card`;清单写了 `titleKey`,`registerUnit` 交的 `messages` 里 `zh` / `en` 都得有那一条;**卡片与它用的 kit 组件问过的每个键也都要有落点**(判据自己当 `t`,没命中就报原始键名)。判据**不断言**"画的是哪一态那一屏" —— 那归你自己那份 `plugin.test.ts` |
15
15
  | `standalone` | "只有工作台源码在场才编得过" ⇒ 发布出去就散架 | `build 在外壳源码不在场时失败` / `typecheck 在外壳源码不在场时失败` | 别引用工作台源码;`tsconfig` 里 `paths` 的值必须是**相对路径**(`"./src/*"`,不是 `"src/*"`) |
16
16
  | `markers` | 内网域名 / 企业内部名泄进要公开发布的包 | `命中内网 npm 源` / `命中内网域名` | 那些值不该写进包里;要配就落到模块自己的配置面,或走用户自己声明的来源 |
17
17
  | `alias` | `@/` 伸进工作台源码 ⇒ 装的人手上没有那份源码 | `…指向外壳源码` | `@/` 只许指自己的 `src/`;跨包的东西走包名 |
18
- | `style` | 模块定义 `.wb-*` 去覆盖外壳的类(全局类名,两份规则按注入顺序打架) | `定义了外壳前缀 wb-* 的 CSS 规则` / `借用了契约里没有的类` | 自己的样式走 `*.module.css`(类名**不带** `wb-` 前缀,构建时按文件路径哈希);外壳给的类只能用契约里列出的那些,要借就写 `:global(.wb-…)` |
18
+ | `style` | 模块定义 `.wb-*` 去覆盖外壳的类(全局类名,两份规则按注入顺序打架) | `定义了外壳前缀 wb-* 的 CSS 规则` / `借用了契约里没有的类` | 自己的样式走 `*.module.css`(类名**不带** `wb-` 前缀,构建时按文件路径哈希);外壳给的类只能用契约里列出的那些,要借就写 `:global(.wb-…)`;被 `样式归属` 判红的手写「标签+控件」行或模块自己管的行距 ⇒ 改用 `FormRow(s)`([KIT.md](KIT.md) §5) |
19
19
 
20
20
  ## 什么时候该怀疑门禁本身
21
21