@skillre/dsh-plugin-work-dashboard 0.10.0 → 0.11.0

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.
package/lib/index.js CHANGED
@@ -102,12 +102,14 @@ export function createRuntime(config, options = {}) {
102
102
  * rather than an error, because a stale browser tab holding an id that was
103
103
  * renamed in the ledger should still produce the projects it can.
104
104
  */
105
- async exportForm(mode, pocIds) {
105
+ async exportForm(mode, pocIds, intent) {
106
106
  await this.prepare();
107
107
  const stamp = now();
108
+ // Default from `mode` so an older Client bundle keeps working.
109
+ const resolved = intent ?? (mode === 'blank' ? 'new' : 'supplement');
108
110
  if (mode === 'blank') {
109
111
  return {
110
- html: buildFormHtml({ mode: 'blank', projects: [], now: stamp }),
112
+ html: buildFormHtml({ mode: 'blank', intent: resolved, projects: [], now: stamp }),
111
113
  fileName: formFileName({ mode: 'blank', pocIds: [], now: stamp }),
112
114
  projectCount: 0,
113
115
  };
@@ -116,7 +118,7 @@ export function createRuntime(config, options = {}) {
116
118
  const records = (await loadOrEmpty()).filter((record) => wanted.has(text(record.poc_id)));
117
119
  const projects = records.map(projectForForm);
118
120
  return {
119
- html: buildFormHtml({ mode: 'fill', projects, now: stamp }),
121
+ html: buildFormHtml({ mode: 'fill', intent: resolved, projects, now: stamp }),
120
122
  fileName: formFileName({ mode: 'fill', pocIds: records.map((record) => text(record.poc_id)), now: stamp }),
121
123
  projectCount: projects.length,
122
124
  };
@@ -45,9 +45,12 @@ export interface ConsoleActions {
45
45
  /**
46
46
  * Build the collection form for one batch.
47
47
  *
48
- * `blank` ignores `pocIds` and returns the new-project form.
48
+ * `intent` decides how much of the page is editable: `new` registers a
49
+ * project, `supplement` fills in the current stage, `progress` appends one
50
+ * round. It defaults from `mode` when omitted, so an older caller keeps
51
+ * working.
49
52
  */
50
- exportForm(mode: 'fill' | 'blank', pocIds: readonly string[]): Promise<ExportFormResult>;
53
+ exportForm(mode: 'fill' | 'blank', pocIds: readonly string[], intent?: 'new' | 'supplement' | 'progress'): Promise<ExportFormResult>;
51
54
  }
52
55
  /**
53
56
  * Build the exact route Connection registers; every failure stays inside the
package/lib/transport.js CHANGED
@@ -33,6 +33,9 @@ const requestSchema = z.discriminatedUnion('action', [
33
33
  z.object({
34
34
  action: z.literal('export-form'),
35
35
  mode: z.union([z.literal('fill'), z.literal('blank')]),
36
+ // Optional so a stale Client bundle (already loaded in a browser tab) keeps
37
+ // working; the Host falls back to deriving it from `mode`.
38
+ intent: z.union([z.literal('new'), z.literal('supplement'), z.literal('progress')]).optional(),
36
39
  // Bounded: a form is meant for a batch a colleague will actually fill in,
37
40
  // and an unbounded list would let one request build a thousands-project
38
41
  // document on the Host.
@@ -77,7 +80,7 @@ async function dispatch(actions, request, signal) {
77
80
  case 'timeline':
78
81
  return actions.timeline();
79
82
  case 'export-form':
80
- return actions.exportForm(request.mode, request.pocIds);
83
+ return actions.exportForm(request.mode, request.pocIds, request.intent);
81
84
  }
82
85
  }
83
86
  export function createExecuteRoute(ready, options = {}) {
package/lib/types.d.ts CHANGED
@@ -236,8 +236,14 @@ export interface OrgRecord {
236
236
  */
237
237
  export interface PocRecord {
238
238
  /**
239
- * The data-shape version, fixed `"3.1"`. A file without it is a v3.0 record
240
- * and is handled as a degraded, read-only shape.
239
+ * The data-shape version, fixed `"3.1"`.
240
+ *
241
+ * Optional only because the reader must not crash on a file that lacks it —
242
+ * the ledger's validator rejects such a file with `E-VERSION`, so a record
243
+ * without this stamp never reaches the cache in a healthy checkout. There is
244
+ * **no v3.0 compatibility mode**: an unstamped record is reported through
245
+ * `RulesProvenance.schemaCurrent`, not silently reinterpreted as an older
246
+ * shape.
241
247
  */
242
248
  schema_version?: string | null;
243
249
  poc_id?: string | null;
@@ -645,6 +651,13 @@ export type PocResult<T> = {
645
651
  details: Record<string, unknown>;
646
652
  };
647
653
  };
654
+ /**
655
+ * What the colleague is doing with a form.
656
+ *
657
+ * Mirrors `FormIntent` in `form.ts`, restated here so the transport contract
658
+ * does not depend on the generator module.
659
+ */
660
+ export type FormIntentKind = 'new' | 'supplement' | 'progress';
648
661
  /** Request kinds accepted by the Host endpoint. */
649
662
  export type PocRequest = {
650
663
  action: 'list';
@@ -661,6 +674,7 @@ export type PocRequest = {
661
674
  action: 'export-form';
662
675
  mode: 'fill' | 'blank';
663
676
  pocIds: string[];
677
+ intent?: FormIntentKind;
664
678
  };
665
679
  /**
666
680
  * One generated collection form, ready for the browser to save.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@skillre/dsh-plugin-work-dashboard",
3
- "version": "0.10.0",
3
+ "version": "0.11.0",
4
4
  "description": "工作看板:多模块运营看板,POC 运营为首个模块(四维结果、阶段轨道、缺口清单、风险看板、时间线、导出表单)",
5
5
  "icon": "./icon.svg",
6
6
  "type": "module",
@@ -54,18 +54,31 @@ node <skill-dir>/scripts/export-form.mjs --mode new --out /tmp/表单-新建.htm
54
54
  | 自动保存 | 停止输入 2 秒后自动存 localStorage;另可随时点【保存】 |
55
55
  | 草稿恢复 | 重新打开自动恢复上次未提交内容 |
56
56
  | 清空草稿 | 顶部按钮 |
57
- | 实时缺口提示 | 顶部显示当前填了多少、还缺哪几项必填 |
58
- | 预览 JSON | 底部按钮,看将交回的结构 |
59
- | 提交并生成文件 | 下载 `poc-changes-<日期>.json` |
57
+ | 实时缺口提示 | 顶部就绪条:五必填进度、陈旧度时钟、计划聚焦 |
58
+ | 按阶段只读 | 已完成的阶段折叠成摘要,只有当前阶段可编辑 |
59
+ | 预览变更集 | 底部按钮,看将交回的 JSON 结构 |
60
+ | 下载变更集 | 下载 `poc-changes-<日期>.json` |
60
61
 
61
62
  存储键由**项目编号**派生(不是时间戳),所以同一个项目的表单重新生成后仍能找到旧草稿。
62
63
 
64
+ ## 导出时先选意图
65
+
66
+ 导出对话框第一步是**这次要做什么**,它决定表单问什么:
67
+
68
+ | 意图 | 表单内容 | 什么时候用 |
69
+ |---|---|---|
70
+ | **新建项目** | 身份 + G0 五必填 | 项目还没进台账 |
71
+ | **补充信息** | 当前阶段该填的,更早阶段只读 | 某个阶段的内容要补全 |
72
+ | **记录进展** | 只展开进展 + 下一步,一屏 | 每周例行同步 |
73
+
74
+ 批量导出时可以**按阶段筛选**(G0 30 · G1 0 …),给「所有 G0 项目」发一份表单。
75
+
63
76
  ## 交给组员时要说清
64
77
 
65
78
  1. **怎么打开**:双击 HTML,用浏览器打开
66
- 2. **填哪些**:灰色区域是台账已有信息,只填需要补充的部分
79
+ 2. **填哪些**:只有标了 `*` 的必填项和当前阶段的区块;灰色的「只读」区块是台账已有信息,不用重填
67
80
  3. **不用怕丢**:自动保存,关掉再打开还在
68
- 4. **填完怎么给你**:点【提交并生成文件】,把下载的 `.json` 用飞书发回
81
+ 4. **填完怎么给你**:点【下载变更集】,把下载的 `poc-changes-<日期>.json` 用飞书发回
69
82
  5. **填不全没关系**:留空的会被标出来,提交时统一校验
70
83
 
71
84
  ## 注意
@@ -21,32 +21,81 @@ description: 校验组员交回的 POC 数据文件(.json),合并进 v3 YA
21
21
 
22
22
  ## 组员交回的 JSON 结构
23
23
 
24
+ **变更集(v3.1)**:只含人填写的字段,**不含任何派生字段**。
25
+
24
26
  ```json
25
27
  {
26
- "generatedAt": "2026-11-06T12:35:00.000Z",
27
- "generatedBy": "POC 表单 v3",
28
- "pocs": {
29
- "POC-006": {
30
- "identity": { "name": "...", "org": { "system": "人保体系", "company": "..." }, "amount_wan": 1500 },
31
- "gate0": { "why_customer": "...", "why_us": "...", "decision_chain": "..." },
32
- "plan": { "criteria": [{ "name": "...", "metric": "...", "target": "..." }], "scenarios": ["..."], "risks": [{ "name": "...", "level": "high", "mitigation": "..." }] },
28
+ "schemaVersion": "3.1",
29
+ "generatedAt": "2026-11-19T05:00:00.000Z",
30
+ "generatedBy": "POC 信息收集表单 v3.1",
31
+ "intent": "supplement",
32
+ "changes": [
33
+ {
34
+ "schema_version": "3.1",
35
+ "poc_id": "POC-006",
36
+ "name": "人保财险全国信创上网行为管理替换",
37
+ "org": { "system": "人保体系", "company": "人保财险", "department": null },
38
+ "amount_wan": 1000,
39
+ "poc_type": "大体量项目",
40
+ "owner": "靳承德/苑炳轩",
41
+ "sales": "林鹤",
42
+ "tech_owner": "李国新",
43
+ "exec_sponsor": null,
44
+ "stage": "G0-立项",
45
+ "status": "进行中",
46
+ "stage_since": null,
47
+ "gate0": {
48
+ "why_customer": "...", "why_us": "...",
49
+ "decision_chain": "...", "post_poc_decision": "...",
50
+ "competitor": "...",
51
+ "review": { "conclusion": "通过", "reviewer": "杨闯", "reviewed_at": "2026-11-19" }
52
+ },
53
+ "plan": {
54
+ "customer_pain": "...", "expected_recognition": "...", "our_edge": "...",
55
+ "criteria": [{ "id": "cri-01", "name": "...", "metric": "...", "baseline": null, "target": "..." }],
56
+ "scenarios": [{ "id": "scn-01", "name": "...", "goal": "..." }],
57
+ "risks": [{ "name": "...", "level": "high", "mitigation": "..." }],
58
+ "timeline": { "start": "2026-11-01", "end": "2027-01-31" },
59
+ "gate1": { "conclusion": null },
60
+ "gate2": { "ready": null }
61
+ },
33
62
  "progress": [
34
63
  {
35
- "date": "2026-11-06",
64
+ "date": "2026-11-19",
36
65
  "type": "客户阶段同步",
37
- "goal": "...", "actual": "...", "completion": "75%",
38
- "evidence": [{ "title": "验收报告.pdf", "link": "https://…", "type": "文档" }],
66
+ "change": "证据补充",
67
+ "goal": "...",
68
+ "scenario_ids": ["scn-01"],
69
+ "criteria_ids": ["cri-01"],
70
+ "actual": "...",
71
+ "completion": "75%",
72
+ "evidence": [{ "title": "压测报告", "link": "https://…", "type": "文档" }],
39
73
  "customer": { "synced_with": "王工", "feedback": "…", "recognition": "部分认可" },
40
74
  "gate3_1": "可证明", "gate3_2": "待确认",
41
75
  "next": { "goal": "...", "owner": "...", "deadline": "2026-12-01" }
42
76
  }
43
- ],
44
- "outcome": { "our_proof": "...", "conclusion": { "proved": "...", "recognized": "...", "next_business": "..." }, "business": { "milestone": "...", "owner": "...", "deadline": "..." } }
77
+ ]
45
78
  }
46
- }
79
+ ]
47
80
  }
48
81
  ```
49
82
 
83
+ ### 三条必须遵守的读取规则
84
+
85
+ | 规则 | 原因 |
86
+ |---|---|
87
+ | **`changes` 是数组**,不是以 `poc_id` 为键的对象 | 一个文件可以装多个项目的变更 |
88
+ | **`null` 表示「没改」**,不是「清空」 | 表单把空字段写成 `null`;合并时 `null` 必须**跳过**,否则会把已有值抹掉 |
89
+ | **没有派生字段** | `gate0.missing`/`complete`、`priority`、场景/指标 `status` 由 `tools/derive.mjs` 算,CI 会重算并校验 |
90
+
91
+ **`intent` 说明这次交回的是什么**:
92
+
93
+ | 值 | 含义 | 合并范围 |
94
+ |---|---|---|
95
+ | `new` | 新建项目 | 整个文件都是新的,派生字段由 CI 首次计算 |
96
+ | `supplement` | 补充当前阶段 | 只合并 `changes[].*` 里非 null 的字段 |
97
+ | `progress` | 只记录了一轮进展 | 只有 `progress[]` 非空,其余字段应全部为 null |
98
+
50
99
  ## 处理步骤
51
100
 
52
101
  ### 1. 校验