@skillre/dsh-plugin-work-dashboard 0.14.0 → 0.15.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.
Files changed (34) hide show
  1. package/README.en.md +5 -8
  2. package/README.md +5 -8
  3. package/lib/client/api.d.ts +3 -3
  4. package/lib/client/api.js +1 -3
  5. package/lib/client.js +18 -16
  6. package/lib/index.js +35 -1
  7. package/lib/report-contract.d.ts +132 -2
  8. package/lib/report-contract.js +126 -0
  9. package/lib/report-form.d.ts +10 -1
  10. package/lib/report-form.js +26 -2
  11. package/lib/report-page.js +1989 -1170
  12. package/lib/report-style.d.ts +24 -13
  13. package/lib/report-style.js +367 -399
  14. package/lib/transport.d.ts +5 -5
  15. package/lib/transport.js +4 -3
  16. package/lib/types.d.ts +5 -3
  17. package/package.json +9 -16
  18. package/compatibility.json +0 -240
  19. package/docs/DESIGN-0.3.md +0 -122
  20. package/docs/DESIGN-1.0-/344/274/230/345/214/226/346/226/271/346/241/210.md +0 -212
  21. package/docs/DESIGN-/344/274/232/350/257/235/344/272/214-SuperAgent/344/270/216/344/273/223/345/272/223/346/224/271/351/200/240.md +0 -275
  22. package/docs/DESIGN-/345/257/274/345/207/272/350/241/250/345/215/225/351/207/215/350/256/276/350/256/241.md +0 -330
  23. package/docs/DESIGN-/346/217/220/351/206/222/344/270/216Gate/350/257/204/345/256/241.md +0 -518
  24. package/docs/DESIGN-/346/226/207/346/234/254/346/210/252/346/226/255.md +0 -565
  25. package/docs/DESIGN-/350/241/250/345/215/225/345/210/206/351/230/266/346/256/265.md +0 -420
  26. package/docs/LEDGER-REQUIREMENTS-v3.1.md +0 -367
  27. package/docs/PLAN-0.7-0.9.md +0 -230
  28. package/docs/PLAN-v3.1-adaptation.md +0 -237
  29. package/docs/POC-3.2-/350/277/233/345/261/225/345/245/221/347/272/246.md +0 -21
  30. package/docs/Super-Agent-3.2-/350/201/224/350/260/203/346/211/213/345/206/214.md +0 -38
  31. package/docs/TARGET-/345/217/260/350/264/246/344/273/223/345/272/223v3.1.md +0 -500
  32. package/docs//350/200/201Mac-SuperAgent/346/224/271/351/200/240/350/256/260/345/275/225-/347/254/254/344/272/214/346/255/245.md +0 -233
  33. package/lib/form.d.ts +0 -597
  34. package/lib/form.js +0 -3211
package/README.en.md CHANGED
@@ -201,20 +201,18 @@ A local tarball is likewise **outside** the official update path.
201
201
 
202
202
  ```sh
203
203
  npm install
204
- npm run check # typecheck + 172 unit tests + lib-drift check + pack check
205
- npm pack # produces skillre-dsh-plugin-work-dashboard-0.4.0.tgz
204
+ npm run check # typecheck + unit tests + pack check
205
+ npm pack # produces skillre-dsh-plugin-<version>.tgz
206
206
  ```
207
207
 
208
- Real mount verification **only against an owned, disposable, non-Desktop profile**:
208
+ Browser verification **only against an owned, disposable, non-Desktop profile**:
209
209
 
210
210
  ```sh
211
- node scripts/verify-isolated.mjs # real clone/fetch/detail/auth/restart-wipe + risks/timeline, self-cleaning
212
211
  node scripts/ui-preview.mjs # boots a bounded Web instance and writes .preview-url.txt
213
212
  node scripts/ui-verify.mjs # browser assertions + docs/evidence/ screenshots
214
- node scripts/verify-market-install.mjs # LIVE index → real install → routes answer (requires a published entry)
215
213
  ```
216
214
 
217
- `ui-preview.mjs` stops its processes and deletes the isolated root it created; `verify-isolated.mjs` cleans up in a `finally` and verifies the root is gone. Every script points `cacheRoot` inside the isolated profile and **never touches your real `~/.dsh/cache`**.
215
+ `ui-preview.mjs` stops its processes and deletes the isolated root it created. The scripts point `cacheRoot` inside the isolated profile and **never touch your real `~/.dsh/cache`**.
218
216
 
219
217
  The UI harness must rebuild and repack before it runs: the preview installs the packed artifact, so verifying without a rebuild would verify the previous build.
220
218
 
@@ -226,10 +224,9 @@ See [UNINSTALL.md](UNINSTALL.md). All data lives in the GitHub repository, so un
226
224
 
227
225
  | DSH version | Result | Verified | Notes |
228
226
  |---|---|---|---|
229
- | 0.2.2-rc.2 | passed | 2026-11-13 | packed install + bounded startup + real clone + 31 isolated checks (incl. the three skills really reaching the skill catalog) + 15 live market npm-install checks (see `compatibility.json`) |
227
+ | 0.2.2-rc.2 | passed | 2026-11-13 | packed install + bounded startup + real clone + 31 isolated checks (incl. the three skills really reaching the skill catalog) + 15 live market npm-install checks (see ``) |
230
228
  | 0.2.2-rc.1 | passed | 2026-11-06 | same behaviour + 69 browser assertions; 0.6.0 does not touch the client bundle, so that record still holds |
231
229
 
232
- Machine-readable evidence is in `compatibility.json`; screenshots and reports are in `docs/evidence/`. **Desktop Client (Electron) was not verified**: its profile is managed by the app and this CLI harness cannot drive it, so a Desktop-specific visual check is still outstanding before Desktop delivery.
233
230
 
234
231
  ## Implementation notes
235
232
 
package/README.md CHANGED
@@ -308,20 +308,18 @@ DSH `0.2.2` 线起,插件详情页有「版本 / Versions」区块,能检查
308
308
 
309
309
  ```sh
310
310
  npm install
311
- npm run check # typecheck + 172 个单测 + lib 漂移检查 + 打包检查
312
- npm pack # 产出 skillre-dsh-plugin-work-dashboard-0.4.0.tgz
311
+ npm run check # typecheck + 单测 + 打包检查
312
+ npm pack # 产出 skillre-dsh-plugin-<version>.tgz
313
313
  ```
314
314
 
315
- **仅使用自己拥有的、可丢弃的非 Desktop profile**做真实挂载验证:
315
+ **仅使用自己拥有的、可丢弃的非 Desktop profile**做浏览器侧验证:
316
316
 
317
317
  ```sh
318
- node scripts/verify-isolated.mjs # 真实 clone/fetch/详情/鉴权/重启清空 + 风险/时间线,结束自清理
319
318
  node scripts/ui-preview.mjs # 起一个有界 Web 实例并写入 .preview-url.txt
320
319
  node scripts/ui-verify.mjs # 浏览器断言 + docs/evidence/ 截图
321
- node scripts/verify-market-install.mjs # 线上索引 → 真实安装 → 动作可用(需已发布)
322
320
  ```
323
321
 
324
- `ui-preview.mjs` 必须在退出前创建 `.preview-stop`,或让它超时;它会停进程、删掉自己创建的隔离根目录。`verify-isolated.mjs` 在 `finally` 里清理并校验根目录已消失。所有脚本都把 `cacheRoot` 指向隔离 profile 内的路径,**不会碰你真实的 `~/.dsh/cache`**。
322
+ `ui-preview.mjs` 必须在退出前创建 `.preview-stop`,或让它超时;它会停进程、删掉自己创建的隔离根目录。脚本把 `cacheRoot` 指向隔离 profile 内的路径,**不会碰你真实的 `~/.dsh/cache`**。
325
323
 
326
324
  ## 卸载与回滚
327
325
 
@@ -331,10 +329,9 @@ node scripts/verify-market-install.mjs # 线上索引 → 真实安装 → 动
331
329
 
332
330
  | DSH 版本 | 结果 | 验证日期 | 说明 |
333
331
  |---|---|---|---|
334
- | 0.2.2-rc.2 | 通过 | 2026-11-13 | 打包安装 + 有界启动 + 真实 clone + 31 项隔离集成(含三个技能确实进入技能目录)+ 15 项线上市场 npm 安装(见 `compatibility.json`) |
332
+ | 0.2.2-rc.2 | 通过 | 2026-11-13 | 打包安装 + 有界启动 + 真实 clone + 31 项隔离集成(含三个技能确实进入技能目录)+ 15 项线上市场 npm 安装(见 ``) |
335
333
  | 0.2.2-rc.1 | 通过 | 2026-11-06 | 同上行为 + 69 项浏览器断言;0.6.0 未改动客户端产物,该记录仍然有效 |
336
334
 
337
- 机器可读证据在 `compatibility.json`,截图与报告在 `docs/evidence/`。**未验证 Desktop Client(Electron)**:它的 profile 由应用管理,本 CLI 测试台无法驱动,Desktop 发布前需在那里重做一次视觉检查。
338
335
 
339
336
  ## 实现说明
340
337
 
@@ -33,10 +33,10 @@ export interface ClientApi {
33
33
  /**
34
34
  * Build the collection form.
35
35
  *
36
- * Generated on the Host because the generator needs the YAML serializer, which
37
- * must not be bundled into the browser module.
36
+ * Generated on the Host because the generator needs the ledger's display
37
+ * projection, which must not be bundled into the browser module.
38
38
  */
39
- exportForm(mode: 'fill' | 'blank', pocIds: readonly string[], intent?: 'new' | 'supplement' | 'progress', signal?: AbortSignal): Promise<ExportFormResult>;
39
+ exportForm(mode: 'fill' | 'blank', pocIds: readonly string[], signal?: AbortSignal): Promise<ExportFormResult>;
40
40
  }
41
41
  /** Create the API bound to this plugin's Fiber lifetime. */
42
42
  export declare function createApi(connection: ClientConnectionLike, lifetime: AbortSignal): ClientApi;
package/lib/client/api.js CHANGED
@@ -40,8 +40,6 @@ export function createApi(connection, lifetime) {
40
40
  detail: (pocId, signal) => call({ action: 'detail', pocId }, signal),
41
41
  risks: (signal) => call({ action: 'risks' }, signal),
42
42
  timeline: (signal) => call({ action: 'timeline' }, signal),
43
- exportForm: (mode, pocIds, intent, signal) => call(intent === undefined
44
- ? { action: 'export-form', mode, pocIds: [...pocIds] }
45
- : { action: 'export-form', mode, pocIds: [...pocIds], intent }, signal),
43
+ exportForm: (mode, pocIds, signal) => call({ action: 'export-form', mode, pocIds: [...pocIds] }, signal),
46
44
  };
47
45
  }
package/lib/client.js CHANGED
@@ -80,6 +80,8 @@ window.__ModuleLoader__.load({
80
80
  this.details = details;
81
81
  this.name = "ActionError";
82
82
  }
83
+ code;
84
+ details;
83
85
  };
84
86
  function unwrap(result) {
85
87
  if (result === null || typeof result !== "object" || !("ok" in result)) {
@@ -99,8 +101,8 @@ window.__ModuleLoader__.load({
99
101
  detail: (pocId, signal) => call({ action: "detail", pocId }, signal),
100
102
  risks: (signal) => call({ action: "risks" }, signal),
101
103
  timeline: (signal) => call({ action: "timeline" }, signal),
102
- exportForm: (mode, pocIds, intent, signal) => call(
103
- intent === void 0 ? { action: "export-form", mode, pocIds: [...pocIds] } : { action: "export-form", mode, pocIds: [...pocIds], intent },
104
+ exportForm: (mode, pocIds, signal) => call(
105
+ { action: "export-form", mode, pocIds: [...pocIds] },
104
106
  signal
105
107
  )
106
108
  };
@@ -1685,13 +1687,13 @@ window.__ModuleLoader__.load({
1685
1687
  var import_react = require("react");
1686
1688
 
1687
1689
  // node_modules/yaml/browser/dist/nodes/identity.js
1688
- var ALIAS = Symbol.for("yaml.alias");
1689
- var DOC = Symbol.for("yaml.document");
1690
- var MAP = Symbol.for("yaml.map");
1691
- var PAIR = Symbol.for("yaml.pair");
1692
- var SCALAR = Symbol.for("yaml.scalar");
1693
- var SEQ = Symbol.for("yaml.seq");
1694
- var NODE_TYPE = Symbol.for("yaml.node.type");
1690
+ var ALIAS = /* @__PURE__ */ Symbol.for("yaml.alias");
1691
+ var DOC = /* @__PURE__ */ Symbol.for("yaml.document");
1692
+ var MAP = /* @__PURE__ */ Symbol.for("yaml.map");
1693
+ var PAIR = /* @__PURE__ */ Symbol.for("yaml.pair");
1694
+ var SCALAR = /* @__PURE__ */ Symbol.for("yaml.scalar");
1695
+ var SEQ = /* @__PURE__ */ Symbol.for("yaml.seq");
1696
+ var NODE_TYPE = /* @__PURE__ */ Symbol.for("yaml.node.type");
1695
1697
  var isAlias = (node) => !!node && typeof node === "object" && node[NODE_TYPE] === ALIAS;
1696
1698
  var isDocument = (node) => !!node && typeof node === "object" && node[NODE_TYPE] === DOC;
1697
1699
  var isMap = (node) => !!node && typeof node === "object" && node[NODE_TYPE] === MAP;
@@ -1721,9 +1723,9 @@ window.__ModuleLoader__.load({
1721
1723
  var hasAnchor = (node) => (isScalar(node) || isCollection(node)) && !!node.anchor;
1722
1724
 
1723
1725
  // node_modules/yaml/browser/dist/visit.js
1724
- var BREAK = Symbol("break visit");
1725
- var SKIP = Symbol("skip children");
1726
- var REMOVE = Symbol("remove node");
1726
+ var BREAK = /* @__PURE__ */ Symbol("break visit");
1727
+ var SKIP = /* @__PURE__ */ Symbol("skip children");
1728
+ var REMOVE = /* @__PURE__ */ Symbol("remove node");
1727
1729
  function visit(node, visitor) {
1728
1730
  const visitor_ = initVisitor(visitor);
1729
1731
  if (isDocument(node)) {
@@ -3890,9 +3892,9 @@ window.__ModuleLoader__.load({
3890
3892
  };
3891
3893
 
3892
3894
  // node_modules/yaml/browser/dist/parse/cst-visit.js
3893
- var BREAK2 = Symbol("break visit");
3894
- var SKIP2 = Symbol("skip children");
3895
- var REMOVE2 = Symbol("remove item");
3895
+ var BREAK2 = /* @__PURE__ */ Symbol("break visit");
3896
+ var SKIP2 = /* @__PURE__ */ Symbol("skip children");
3897
+ var REMOVE2 = /* @__PURE__ */ Symbol("remove item");
3896
3898
  function visit2(cst, visitor) {
3897
3899
  if ("type" in cst && cst.type === "document")
3898
3900
  cst = { start: cst.start, value: cst.value };
@@ -4680,7 +4682,7 @@ window.__ModuleLoader__.load({
4680
4682
  setBusy(true);
4681
4683
  try {
4682
4684
  const mode = intent === "new" ? "blank" : "fill";
4683
- const result = await api.exportForm(mode, mode === "blank" ? [] : selectedIds, intent);
4685
+ const result = await api.exportForm(mode, mode === "blank" ? [] : selectedIds);
4684
4686
  const files = Array.isArray(result.files) ? result.files : [];
4685
4687
  if (files.length === 0) throw new Error(t("exportFailed"));
4686
4688
  for (const [index, file] of files.entries()) {
package/lib/index.js CHANGED
@@ -20,6 +20,7 @@ import { buildRiskBoard } from './risks.js';
20
20
  import { buildGlobalTimeline } from './timeline.js';
21
21
  import { text } from './gap.js';
22
22
  import { canReportProgress } from './progress.js';
23
+ import { buildDossier } from './report-contract.js';
23
24
  import { buildReportHtml, reportFileName, reportFileNames } from './report-form.js';
24
25
  import { registerBundledSkills } from './skill.js';
25
26
  import { createExecuteRoute } from './transport.js';
@@ -69,6 +70,36 @@ export function createRuntime(config, options = {}) {
69
70
  throw error;
70
71
  }
71
72
  };
73
+ /**
74
+ * The read-only dossier for one project, for the form's second page.
75
+ *
76
+ * `detail()` already computes the summary, the derived scenario/criteria
77
+ * statuses and the gap scan the dossier shows, so this reads it rather than
78
+ * re-deriving them: a second derivation would be a second answer to the same
79
+ * question, and the two would drift.
80
+ *
81
+ * A project whose detail cannot be built still gets a form — the dossier is
82
+ * context, and missing context must not block recording progress. `null` makes
83
+ * the page render its "档案暂不可用" state instead of failing the export.
84
+ */
85
+ const dossierFor = async (record) => {
86
+ try {
87
+ const detail = await store.detail(text(record.poc_id));
88
+ if (!detail)
89
+ return null;
90
+ const achieved = detail.plan.criteria.filter((criterion) => criterion.status === '已达成').length;
91
+ return buildDossier(record, {
92
+ daysInStage: detail.summary.daysInStage,
93
+ stageSince: detail.summary.stageSince ?? '',
94
+ g0Conclusion: detail.summary.g0Conclusion,
95
+ g0Complete: detail.summary.g0Complete,
96
+ unverifiedCriteria: detail.plan.criteria.length - achieved,
97
+ });
98
+ }
99
+ catch {
100
+ return null;
101
+ }
102
+ };
72
103
  return {
73
104
  async prepare() {
74
105
  prepared ??= cache.prepare();
@@ -128,8 +159,11 @@ export function createRuntime(config, options = {}) {
128
159
  const names = reportFileNames('progress', records.map((record) => ({
129
160
  name: text(record.name), owner: text(record.owner), pocId: text(record.poc_id),
130
161
  })), stamp);
162
+ // Build the dossier before mapping: `map` cannot await, and a project's
163
+ // dossier must be ready when its document is assembled.
164
+ const dossiers = await Promise.all(records.map((record) => dossierFor(record)));
131
165
  const files = records.map((record, index) => ({
132
- html: buildReportHtml('progress', [record], stamp),
166
+ html: buildReportHtml('progress', [record], stamp, dossiers[index] ?? null),
133
167
  fileName: names[index] ?? '记录进展.html',
134
168
  projectCount: 1,
135
169
  pocId: text(record.poc_id),
@@ -130,10 +130,10 @@ export declare const reportSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
130
130
  amount_wan: z.ZodOptional<z.ZodNumber>;
131
131
  poc_type: z.ZodOptional<z.ZodEnum<{
132
132
  大体量项目: "大体量项目";
133
- SDL: "SDL";
134
- ACG: "ACG";
135
133
  AI安全: "AI安全";
136
134
  保护AI: "保护AI";
135
+ ACG: "ACG";
136
+ SDL: "SDL";
137
137
  虚拟化: "虚拟化";
138
138
  }>>;
139
139
  exec_sponsor: z.ZodOptional<z.ZodString>;
@@ -312,4 +312,134 @@ export interface ReportPlan {
312
312
  export declare function previousPlans(project: PocRecord): ReportPlan[];
313
313
  /** Stable report-derived read data. Never treat colleague-reported status as a review verdict. */
314
314
  export declare function structuredSummary(roundRecord: ProgressRecord): string;
315
+ /**
316
+ * What the colleague needs to read before answering this round.
317
+ *
318
+ * The export used to carry only the previous plan, so a form opened as a blank
319
+ * grid attached to nothing: the person filling it in had no way to know what the
320
+ * project was for, what had already been tried, or what was still missing. This
321
+ * projection is the whole project, flattened for a page that has no ledger and
322
+ * no network.
323
+ *
324
+ * It is a **snapshot**, taken at export time, and strictly read-only. Every
325
+ * field is already resolved to a string or a plain object — the page must never
326
+ * reach back into `PocRecord`, because the record is not in the file.
327
+ *
328
+ * Deliberate shape choices:
329
+ *
330
+ * - `text` fields keep `''` for "not filled" instead of being omitted. The page
331
+ * renders "台账未填写" from the empty string; a missing key would force the
332
+ * page to invent a reason it cannot know.
333
+ * - `rounds` is capped by the caller, not here. The projection reports every
334
+ * round it was given plus `roundTotal`, so the page can say "还有 N 轮未展开".
335
+ */
336
+ export interface DossierRound {
337
+ seq: string;
338
+ date: string;
339
+ type: string;
340
+ change: string;
341
+ /** `实测 91.2% …` — the round's own words, already joined. */
342
+ actual: string;
343
+ /** Structured lines when the round has them, else `[]`. */
344
+ lines: Array<{
345
+ title: string;
346
+ status: string;
347
+ actual: string;
348
+ }>;
349
+ completion: string;
350
+ evidenceCount: number;
351
+ /** `scn-01 · cri-02`, or `''`. */
352
+ ids: string;
353
+ customer: string;
354
+ }
355
+ export interface DossierProject {
356
+ pocId: string;
357
+ name: string;
358
+ stage: string;
359
+ status: string;
360
+ owner: string;
361
+ company: string;
362
+ department: string;
363
+ system: string;
364
+ sales: string;
365
+ techOwner: string;
366
+ execSponsor: string;
367
+ amountWan: string;
368
+ pocType: string;
369
+ /** Whole days in the current stage; `null` when the ledger has no `stage_since`. */
370
+ daysInStage: number | null;
371
+ /** `已导出的那一刻`, `''` when never fetched. */
372
+ stageSince: string;
373
+ g0Conclusion: string;
374
+ g0Complete: boolean;
375
+ gate0: {
376
+ whyCustomer: string;
377
+ whyUs: string;
378
+ decisionChain: string;
379
+ postPocDecision: string;
380
+ competitor: string;
381
+ /** Field keys still empty, in schema order: `['decision_chain', …]`. */
382
+ missing: string[];
383
+ };
384
+ plan: {
385
+ customerPain: string;
386
+ expectedRecognition: string;
387
+ ourEdge: string;
388
+ timelineStart: string;
389
+ timelineEnd: string;
390
+ criteria: Array<{
391
+ id: string;
392
+ name: string;
393
+ metric: string;
394
+ status: string;
395
+ }>;
396
+ scenarios: Array<{
397
+ id: string;
398
+ name: string;
399
+ goal: string;
400
+ status: string;
401
+ evidenceCount: number;
402
+ }>;
403
+ risks: Array<{
404
+ name: string;
405
+ level: string;
406
+ mitigation: string;
407
+ }>;
408
+ };
409
+ /** Newest first, already capped. */
410
+ rounds: DossierRound[];
411
+ /** How many rounds the ledger holds, for the "还有 N 轮" line. */
412
+ roundTotal: number;
413
+ outcome: {
414
+ achievement: string;
415
+ proved: string;
416
+ recognized: string;
417
+ nextBusiness: string;
418
+ overall: string;
419
+ };
420
+ /** Derived counters the "现在卡在哪" row shows. */
421
+ gaps: {
422
+ stalled: boolean;
423
+ stalledDays: number | null;
424
+ unverifiedCriteria: number;
425
+ g0Missing: number;
426
+ pendingPlans: number;
427
+ };
428
+ }
429
+ /** Flatten one round for the dossier list. */
430
+ export declare function dossierRound(entry: ProgressRecord): DossierRound;
431
+ /**
432
+ * Build the read-only dossier embedded in every progress form.
433
+ *
434
+ * `recentRounds` is the caller's cap. Two is the default the user chose: enough
435
+ * to see what was promised and what happened, few enough that a project with
436
+ * forty rounds still opens instantly.
437
+ */
438
+ export declare function buildDossier(project: PocRecord, summary: {
439
+ daysInStage: number | null;
440
+ stageSince: string;
441
+ g0Conclusion: string;
442
+ g0Complete: boolean;
443
+ unverifiedCriteria: number;
444
+ }, recentRounds?: number): DossierProject;
315
445
  export {};
@@ -117,3 +117,129 @@ export function previousPlans(project) {
117
117
  export function structuredSummary(roundRecord) {
118
118
  return (roundRecord.lines ?? []).map((item) => `${item.title}(${item.status}):${item.actual}`).join('\n');
119
119
  }
120
+ const one = (value) => (typeof value === 'string' ? value.trim() : '');
121
+ /** Join the parts of a round that a reader can use, skipping the empties. */
122
+ function roundCustomer(entry) {
123
+ const synced = one(entry.customer?.synced_with);
124
+ const feedback = one(entry.customer?.feedback);
125
+ const recognition = one(entry.customer?.recognition);
126
+ if (!synced && !feedback && !recognition)
127
+ return '';
128
+ const who = synced ? `已同步 ${synced}` : '已同步';
129
+ const said = feedback || recognition;
130
+ return said ? `${who} · ${said}` : who;
131
+ }
132
+ function roundIds(entry) {
133
+ const list = [...(entry.scenario_ids ?? []), ...(entry.criteria_ids ?? [])].map(one).filter((id) => id !== '');
134
+ return list.join(' · ');
135
+ }
136
+ /** Flatten one round for the dossier list. */
137
+ export function dossierRound(entry) {
138
+ const seq = Number.isSafeInteger(entry.seq) && (entry.seq ?? 0) > 0 ? String(entry.seq) : '';
139
+ const lines = (entry.lines ?? []).map((line) => ({
140
+ title: one(line.title),
141
+ status: one(line.status),
142
+ actual: one(line.actual),
143
+ }));
144
+ return {
145
+ seq,
146
+ date: one(entry.date),
147
+ type: one(entry.type),
148
+ change: one(entry.change),
149
+ actual: structuredSummary(entry) || one(entry.actual),
150
+ lines,
151
+ completion: one(entry.completion),
152
+ evidenceCount: Array.isArray(entry.evidence) ? entry.evidence.length : 0,
153
+ ids: roundIds(entry),
154
+ customer: roundCustomer(entry),
155
+ };
156
+ }
157
+ /**
158
+ * Build the read-only dossier embedded in every progress form.
159
+ *
160
+ * `recentRounds` is the caller's cap. Two is the default the user chose: enough
161
+ * to see what was promised and what happened, few enough that a project with
162
+ * forty rounds still opens instantly.
163
+ */
164
+ export function buildDossier(project, summary, recentRounds = 2) {
165
+ const org = project.org ?? {};
166
+ const gate0 = project.gate0 ?? {};
167
+ const plan = project.plan ?? {};
168
+ const outcome = project.outcome ?? {};
169
+ const progress = Array.isArray(project.progress) ? project.progress : [];
170
+ const criteria = (plan.criteria ?? []).map((item) => ({
171
+ id: one(item?.id),
172
+ name: one(item?.name),
173
+ metric: [one(item?.metric), one(item?.target) ? `目标 ${one(item?.target)}` : ''].filter((part) => part !== '').join(' · '),
174
+ status: one(item?.status),
175
+ }));
176
+ const scenarios = (plan.scenarios ?? []).map((item) => ({
177
+ id: one(item?.id),
178
+ name: one(item?.name),
179
+ goal: one(item?.goal),
180
+ status: one(item?.status),
181
+ evidenceCount: typeof item?.evidence_count === 'number' ? item.evidence_count : 0,
182
+ }));
183
+ const missing = (Array.isArray(gate0.missing) ? gate0.missing : [])
184
+ .map(one)
185
+ .filter((field) => field !== '');
186
+ const nextPlans = previousPlans(project);
187
+ const rounds = progress.slice(-recentRounds).reverse().map(dossierRound);
188
+ return {
189
+ pocId: one(project.poc_id),
190
+ name: one(project.name),
191
+ stage: one(project.stage),
192
+ status: one(project.status),
193
+ owner: one(project.owner),
194
+ company: one(org.company),
195
+ department: one(org.department),
196
+ system: one(org.system),
197
+ sales: one(project.sales),
198
+ techOwner: one(project.tech_owner),
199
+ execSponsor: one(project.exec_sponsor),
200
+ amountWan: typeof project.amount_wan === 'number' && Number.isFinite(project.amount_wan) ? String(project.amount_wan) : '',
201
+ pocType: one(project.poc_type),
202
+ daysInStage: summary.daysInStage,
203
+ stageSince: summary.stageSince,
204
+ g0Conclusion: summary.g0Conclusion,
205
+ g0Complete: summary.g0Complete,
206
+ gate0: {
207
+ whyCustomer: one(gate0.why_customer),
208
+ whyUs: one(gate0.why_us),
209
+ decisionChain: one(gate0.decision_chain),
210
+ postPocDecision: one(gate0.post_poc_decision),
211
+ competitor: one(gate0.competitor),
212
+ missing,
213
+ },
214
+ plan: {
215
+ customerPain: one(plan.customer_pain),
216
+ expectedRecognition: one(plan.expected_recognition),
217
+ ourEdge: one(plan.our_edge),
218
+ timelineStart: one(plan.timeline?.start),
219
+ timelineEnd: one(plan.timeline?.end),
220
+ criteria,
221
+ scenarios,
222
+ risks: (plan.risks ?? []).map((item) => ({
223
+ name: one(item?.name),
224
+ level: one(item?.level),
225
+ mitigation: one(item?.mitigation),
226
+ })),
227
+ },
228
+ rounds,
229
+ roundTotal: progress.length,
230
+ outcome: {
231
+ achievement: one(outcome.achievement),
232
+ proved: one(outcome.conclusion?.proved),
233
+ recognized: one(outcome.conclusion?.recognized),
234
+ nextBusiness: one(outcome.conclusion?.next_business),
235
+ overall: one(outcome.overall),
236
+ },
237
+ gaps: {
238
+ stalled: summary.daysInStage !== null && summary.daysInStage > 14,
239
+ stalledDays: summary.daysInStage,
240
+ unverifiedCriteria: summary.unverifiedCriteria,
241
+ g0Missing: missing.length,
242
+ pendingPlans: nextPlans.length,
243
+ },
244
+ };
245
+ }
@@ -1,5 +1,14 @@
1
+ import type { DossierProject } from './report-contract.js';
1
2
  import type { PocRecord } from './types.js';
2
- export declare function buildReportHtml(intent: 'new' | 'progress', records: readonly PocRecord[], now?: Date): string;
3
+ /**
4
+ * Build one collection form.
5
+ *
6
+ * `dossier` is the project's read-only second page. It is optional because the
7
+ * two callers differ: the Host always has the ledger and passes it, while a
8
+ * blank new-project form has no project to describe. A `null` dossier is also
9
+ * legal — the page then shows "档案暂不可用" rather than a half-rendered one.
10
+ */
11
+ export declare function buildReportHtml(intent: 'new' | 'progress', records: readonly PocRecord[], now?: Date, dossier?: DossierProject | null): string;
3
12
  /**
4
13
  * The suggested download name for one form file.
5
14
  *
@@ -9,7 +9,15 @@ function calendarDate(now) {
9
9
  const parts = new Intl.DateTimeFormat('en-CA', { timeZone: 'Asia/Shanghai', year: 'numeric', month: '2-digit', day: '2-digit' }).formatToParts(now);
10
10
  return ['year', 'month', 'day'].map((kind) => parts.find((part) => part.type === kind)?.value).join('-');
11
11
  }
12
- export function buildReportHtml(intent, records, now = new Date()) {
12
+ /**
13
+ * Build one collection form.
14
+ *
15
+ * `dossier` is the project's read-only second page. It is optional because the
16
+ * two callers differ: the Host always has the ledger and passes it, while a
17
+ * blank new-project form has no project to describe. A `null` dossier is also
18
+ * legal — the page then shows "档案暂不可用" rather than a half-rendered one.
19
+ */
20
+ export function buildReportHtml(intent, records, now = new Date(), dossier = null) {
13
21
  if (records.length > MAX_REPORT_PROJECTS)
14
22
  throw new Error(`最多可导出 ${MAX_REPORT_PROJECTS} 个项目`);
15
23
  if (intent === 'progress') {
@@ -26,15 +34,31 @@ export function buildReportHtml(intent, records, now = new Date()) {
26
34
  scenarios: (project.plan?.scenarios ?? []).flatMap((item) => item.id && /^scn-\d{2,3}$/.test(item.id) ? [{ id: item.id, name: item.name ?? item.id }] : []),
27
35
  criteria: (project.plan?.criteria ?? []).flatMap((item) => item.id && /^cri-\d{2,3}$/.test(item.id) ? [{ id: item.id, name: item.name ?? item.id }] : []),
28
36
  }));
37
+ const today = calendarDate(now);
29
38
  return `<!doctype html>
30
39
  <html lang="zh-CN"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1">
31
40
  <meta http-equiv="Content-Security-Policy" content="default-src 'none'; script-src 'unsafe-inline'; style-src 'unsafe-inline'; form-action 'none'; base-uri 'none'">
32
41
  <title>${title}</title><style>${REPORT_STYLE}</style></head><body>
33
42
  <main id="app" class="rp-app"></main><noscript>请下载文件,用启用了 JavaScript 的浏览器打开。无需联网。</noscript>
34
- <script type="application/json" id="poc-report-input">${scriptJSON({ intent, today: calendarDate(now), form_id: randomUUID(), projects, enums: REPORT_ENUMS })}</script>
43
+ <script type="application/json" id="poc-report-input">${scriptJSON({ intent, today, form_id: randomUUID(), exported_at: exportedAt(now), projects, dossier, enums: REPORT_ENUMS })}</script>
35
44
  <script id="poc-form-script">${REPORT_PAGE_SCRIPT.replace(/<\/script/gi, '<\\/script')}</script>
36
45
  </body></html>`;
37
46
  }
47
+ /**
48
+ * The moment the snapshot was taken, printed on both pages.
49
+ *
50
+ * The dossier is a snapshot, so it has to say when it was taken — otherwise a
51
+ * form re-opened a month later presents stale facts as current. Rendered in
52
+ * Asia/Shanghai because every project in this ledger is reported from there.
53
+ */
54
+ function exportedAt(now) {
55
+ const parts = new Intl.DateTimeFormat('zh-CN', {
56
+ timeZone: 'Asia/Shanghai', year: 'numeric', month: '2-digit', day: '2-digit',
57
+ hour: '2-digit', minute: '2-digit', hour12: false,
58
+ }).formatToParts(now);
59
+ const get = (kind) => parts.find((part) => part.type === kind)?.value ?? '';
60
+ return `${get('year')}-${get('month')}-${get('day')} ${get('hour')}:${get('minute')}`;
61
+ }
38
62
  /**
39
63
  * One part of a download name: readable, but never path-like.
40
64
  *