@skillre/dsh-plugin-work-dashboard 0.12.0 → 0.13.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/README.en.md +3 -3
- package/README.md +8 -15
- package/docs/POC-3.2-/350/277/233/345/261/225/345/245/221/347/272/246.md +21 -0
- package/docs/Super-Agent-3.2-/350/201/224/350/260/203/346/211/213/345/206/214.md +38 -0
- package/lib/client/css/detail.d.ts +1 -1
- package/lib/client/css/detail.js +4 -0
- package/lib/client/text.js +6 -10
- package/lib/client.js +72 -36
- package/lib/form.js +118 -35
- package/lib/gap.d.ts +2 -2
- package/lib/gap.js +21 -14
- package/lib/index.js +12 -13
- package/lib/progress.d.ts +8 -0
- package/lib/progress.js +20 -0
- package/lib/report-contract.d.ts +315 -0
- package/lib/report-contract.js +119 -0
- package/lib/report-form.d.ts +3 -0
- package/lib/report-form.js +41 -0
- package/lib/report-import.d.ts +9 -0
- package/lib/report-import.js +118 -0
- package/lib/report-page.d.ts +60 -0
- package/lib/report-page.js +3424 -0
- package/lib/report-style.d.ts +17 -0
- package/lib/report-style.js +459 -0
- package/lib/store.js +8 -4
- package/lib/timeline.js +7 -6
- package/lib/types.d.ts +38 -2
- package/package.json +1 -1
- package/skills/poc-export/SKILL.md +10 -125
- package/skills/poc-export/scripts/export-form.mjs +15 -69
- package/skills/poc-ledger/SKILL.md +14 -25
- package/skills/poc-submit/SKILL.md +13 -278
- package/skills/poc-submit/prepare-return.mjs +48 -0
|
@@ -0,0 +1,315 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import type { PocRecord, ProgressRecord } from './types.js';
|
|
3
|
+
export declare const LEDGER_VERSION = "3.2";
|
|
4
|
+
export declare const REPORT_FORMAT = "poc-report/1";
|
|
5
|
+
export declare const REPORT_DATA_ID = "poc-return-data";
|
|
6
|
+
export declare const MAX_REPORT_BYTES: number;
|
|
7
|
+
export declare const MAX_REPORT_PROJECTS = 200;
|
|
8
|
+
export declare const REPORT_ENUMS: {
|
|
9
|
+
readonly type: readonly ["内部Review", "客户阶段同步", "Checkpoint"];
|
|
10
|
+
readonly change: readonly ["阶段推进", "场景新增", "目标调整", "证据补充", "风险出现", "风险解除", "无实质进展"];
|
|
11
|
+
readonly status: readonly ["已完成", "进行中", "未开始", "延期", "取消"];
|
|
12
|
+
readonly evidence: readonly ["文档", "截图", "数据", "邮件", "链接"];
|
|
13
|
+
readonly completion: readonly ["0%", "25%", "50%", "75%", "100%"];
|
|
14
|
+
readonly system: readonly ["人保体系", "国寿体系"];
|
|
15
|
+
readonly poc_type: readonly ["AI安全", "保护AI", "ACG", "SDL", "虚拟化", "大体量项目"];
|
|
16
|
+
readonly risk: readonly ["high", "medium", "low"];
|
|
17
|
+
};
|
|
18
|
+
export declare const projectId: z.ZodString;
|
|
19
|
+
declare const line: z.ZodObject<{
|
|
20
|
+
plan_id: z.ZodOptional<z.ZodUnion<[z.ZodTemplateLiteral<`plan-${string}`>, z.ZodString]>>;
|
|
21
|
+
title: z.ZodString;
|
|
22
|
+
status: z.ZodEnum<{
|
|
23
|
+
未开始: "未开始";
|
|
24
|
+
取消: "取消";
|
|
25
|
+
进行中: "进行中";
|
|
26
|
+
已完成: "已完成";
|
|
27
|
+
延期: "延期";
|
|
28
|
+
}>;
|
|
29
|
+
actual: z.ZodString;
|
|
30
|
+
evidence: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
31
|
+
title: z.ZodString;
|
|
32
|
+
link: z.ZodOptional<z.ZodString>;
|
|
33
|
+
type: z.ZodOptional<z.ZodEnum<{
|
|
34
|
+
文档: "文档";
|
|
35
|
+
截图: "截图";
|
|
36
|
+
数据: "数据";
|
|
37
|
+
邮件: "邮件";
|
|
38
|
+
链接: "链接";
|
|
39
|
+
}>>;
|
|
40
|
+
}, z.core.$strict>>>;
|
|
41
|
+
customer: z.ZodOptional<z.ZodObject<{
|
|
42
|
+
synced_with: z.ZodOptional<z.ZodString>;
|
|
43
|
+
feedback: z.ZodOptional<z.ZodString>;
|
|
44
|
+
}, z.core.$strict>>;
|
|
45
|
+
scenario_ids: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
46
|
+
criteria_ids: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
47
|
+
completion: z.ZodOptional<z.ZodEnum<{
|
|
48
|
+
"0%": "0%";
|
|
49
|
+
"25%": "25%";
|
|
50
|
+
"50%": "50%";
|
|
51
|
+
"75%": "75%";
|
|
52
|
+
"100%": "100%";
|
|
53
|
+
}>>;
|
|
54
|
+
}, z.core.$strict>;
|
|
55
|
+
declare const round: z.ZodObject<{
|
|
56
|
+
submission_id: z.ZodUUID;
|
|
57
|
+
date: z.ZodISODate;
|
|
58
|
+
type: z.ZodEnum<{
|
|
59
|
+
内部Review: "内部Review";
|
|
60
|
+
客户阶段同步: "客户阶段同步";
|
|
61
|
+
Checkpoint: "Checkpoint";
|
|
62
|
+
}>;
|
|
63
|
+
change: z.ZodEnum<{
|
|
64
|
+
阶段推进: "阶段推进";
|
|
65
|
+
场景新增: "场景新增";
|
|
66
|
+
目标调整: "目标调整";
|
|
67
|
+
证据补充: "证据补充";
|
|
68
|
+
风险出现: "风险出现";
|
|
69
|
+
风险解除: "风险解除";
|
|
70
|
+
无实质进展: "无实质进展";
|
|
71
|
+
}>;
|
|
72
|
+
lines: z.ZodArray<z.ZodObject<{
|
|
73
|
+
plan_id: z.ZodOptional<z.ZodUnion<[z.ZodTemplateLiteral<`plan-${string}`>, z.ZodString]>>;
|
|
74
|
+
title: z.ZodString;
|
|
75
|
+
status: z.ZodEnum<{
|
|
76
|
+
未开始: "未开始";
|
|
77
|
+
取消: "取消";
|
|
78
|
+
进行中: "进行中";
|
|
79
|
+
已完成: "已完成";
|
|
80
|
+
延期: "延期";
|
|
81
|
+
}>;
|
|
82
|
+
actual: z.ZodString;
|
|
83
|
+
evidence: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
84
|
+
title: z.ZodString;
|
|
85
|
+
link: z.ZodOptional<z.ZodString>;
|
|
86
|
+
type: z.ZodOptional<z.ZodEnum<{
|
|
87
|
+
文档: "文档";
|
|
88
|
+
截图: "截图";
|
|
89
|
+
数据: "数据";
|
|
90
|
+
邮件: "邮件";
|
|
91
|
+
链接: "链接";
|
|
92
|
+
}>>;
|
|
93
|
+
}, z.core.$strict>>>;
|
|
94
|
+
customer: z.ZodOptional<z.ZodObject<{
|
|
95
|
+
synced_with: z.ZodOptional<z.ZodString>;
|
|
96
|
+
feedback: z.ZodOptional<z.ZodString>;
|
|
97
|
+
}, z.core.$strict>>;
|
|
98
|
+
scenario_ids: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
99
|
+
criteria_ids: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
100
|
+
completion: z.ZodOptional<z.ZodEnum<{
|
|
101
|
+
"0%": "0%";
|
|
102
|
+
"25%": "25%";
|
|
103
|
+
"50%": "50%";
|
|
104
|
+
"75%": "75%";
|
|
105
|
+
"100%": "100%";
|
|
106
|
+
}>>;
|
|
107
|
+
}, z.core.$strict>>;
|
|
108
|
+
next_plans: z.ZodArray<z.ZodObject<{
|
|
109
|
+
id: z.ZodTemplateLiteral<`plan-${string}`>;
|
|
110
|
+
goal: z.ZodString;
|
|
111
|
+
owner: z.ZodString;
|
|
112
|
+
deadline: z.ZodISODate;
|
|
113
|
+
}, z.core.$strict>>;
|
|
114
|
+
}, z.core.$strict>;
|
|
115
|
+
export declare const reportSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
116
|
+
intent: z.ZodLiteral<"new">;
|
|
117
|
+
changes: z.ZodTuple<[z.ZodObject<{
|
|
118
|
+
poc_id: z.ZodString;
|
|
119
|
+
identity: z.ZodObject<{
|
|
120
|
+
name: z.ZodString;
|
|
121
|
+
owner: z.ZodString;
|
|
122
|
+
company: z.ZodString;
|
|
123
|
+
tech_owner: z.ZodString;
|
|
124
|
+
system: z.ZodOptional<z.ZodEnum<{
|
|
125
|
+
人保体系: "人保体系";
|
|
126
|
+
国寿体系: "国寿体系";
|
|
127
|
+
}>>;
|
|
128
|
+
department: z.ZodOptional<z.ZodString>;
|
|
129
|
+
sales: z.ZodOptional<z.ZodString>;
|
|
130
|
+
amount_wan: z.ZodOptional<z.ZodNumber>;
|
|
131
|
+
poc_type: z.ZodOptional<z.ZodEnum<{
|
|
132
|
+
大体量项目: "大体量项目";
|
|
133
|
+
SDL: "SDL";
|
|
134
|
+
ACG: "ACG";
|
|
135
|
+
AI安全: "AI安全";
|
|
136
|
+
保护AI: "保护AI";
|
|
137
|
+
虚拟化: "虚拟化";
|
|
138
|
+
}>>;
|
|
139
|
+
exec_sponsor: z.ZodOptional<z.ZodString>;
|
|
140
|
+
}, z.core.$strict>;
|
|
141
|
+
gate0: z.ZodObject<{
|
|
142
|
+
why_customer: z.ZodString;
|
|
143
|
+
why_us: z.ZodString;
|
|
144
|
+
decision_chain: z.ZodString;
|
|
145
|
+
post_poc_decision: z.ZodString;
|
|
146
|
+
competitor: z.ZodOptional<z.ZodString>;
|
|
147
|
+
}, z.core.$strict>;
|
|
148
|
+
round: z.ZodOptional<z.ZodObject<{
|
|
149
|
+
submission_id: z.ZodUUID;
|
|
150
|
+
date: z.ZodISODate;
|
|
151
|
+
type: z.ZodEnum<{
|
|
152
|
+
内部Review: "内部Review";
|
|
153
|
+
客户阶段同步: "客户阶段同步";
|
|
154
|
+
Checkpoint: "Checkpoint";
|
|
155
|
+
}>;
|
|
156
|
+
change: z.ZodEnum<{
|
|
157
|
+
阶段推进: "阶段推进";
|
|
158
|
+
场景新增: "场景新增";
|
|
159
|
+
目标调整: "目标调整";
|
|
160
|
+
证据补充: "证据补充";
|
|
161
|
+
风险出现: "风险出现";
|
|
162
|
+
风险解除: "风险解除";
|
|
163
|
+
无实质进展: "无实质进展";
|
|
164
|
+
}>;
|
|
165
|
+
lines: z.ZodArray<z.ZodObject<{
|
|
166
|
+
plan_id: z.ZodOptional<z.ZodUnion<[z.ZodTemplateLiteral<`plan-${string}`>, z.ZodString]>>;
|
|
167
|
+
title: z.ZodString;
|
|
168
|
+
status: z.ZodEnum<{
|
|
169
|
+
未开始: "未开始";
|
|
170
|
+
取消: "取消";
|
|
171
|
+
进行中: "进行中";
|
|
172
|
+
已完成: "已完成";
|
|
173
|
+
延期: "延期";
|
|
174
|
+
}>;
|
|
175
|
+
actual: z.ZodString;
|
|
176
|
+
evidence: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
177
|
+
title: z.ZodString;
|
|
178
|
+
link: z.ZodOptional<z.ZodString>;
|
|
179
|
+
type: z.ZodOptional<z.ZodEnum<{
|
|
180
|
+
文档: "文档";
|
|
181
|
+
截图: "截图";
|
|
182
|
+
数据: "数据";
|
|
183
|
+
邮件: "邮件";
|
|
184
|
+
链接: "链接";
|
|
185
|
+
}>>;
|
|
186
|
+
}, z.core.$strict>>>;
|
|
187
|
+
customer: z.ZodOptional<z.ZodObject<{
|
|
188
|
+
synced_with: z.ZodOptional<z.ZodString>;
|
|
189
|
+
feedback: z.ZodOptional<z.ZodString>;
|
|
190
|
+
}, z.core.$strict>>;
|
|
191
|
+
scenario_ids: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
192
|
+
criteria_ids: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
193
|
+
completion: z.ZodOptional<z.ZodEnum<{
|
|
194
|
+
"0%": "0%";
|
|
195
|
+
"25%": "25%";
|
|
196
|
+
"50%": "50%";
|
|
197
|
+
"75%": "75%";
|
|
198
|
+
"100%": "100%";
|
|
199
|
+
}>>;
|
|
200
|
+
}, z.core.$strict>>;
|
|
201
|
+
next_plans: z.ZodArray<z.ZodObject<{
|
|
202
|
+
id: z.ZodTemplateLiteral<`plan-${string}`>;
|
|
203
|
+
goal: z.ZodString;
|
|
204
|
+
owner: z.ZodString;
|
|
205
|
+
deadline: z.ZodISODate;
|
|
206
|
+
}, z.core.$strict>>;
|
|
207
|
+
}, z.core.$strict>>;
|
|
208
|
+
stage_notes: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
209
|
+
stage: z.ZodEnum<{
|
|
210
|
+
G0: "G0";
|
|
211
|
+
G1: "G1";
|
|
212
|
+
G2: "G2";
|
|
213
|
+
G4: "G4";
|
|
214
|
+
}>;
|
|
215
|
+
text: z.ZodString;
|
|
216
|
+
}, z.core.$strict>>>;
|
|
217
|
+
}, z.core.$strict>], null>;
|
|
218
|
+
format: z.ZodLiteral<"poc-report/1">;
|
|
219
|
+
ledger_version: z.ZodLiteral<"3.2">;
|
|
220
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
221
|
+
intent: z.ZodLiteral<"progress">;
|
|
222
|
+
changes: z.ZodArray<z.ZodObject<{
|
|
223
|
+
poc_id: z.ZodString;
|
|
224
|
+
base: z.ZodString;
|
|
225
|
+
round: z.ZodObject<{
|
|
226
|
+
submission_id: z.ZodUUID;
|
|
227
|
+
date: z.ZodISODate;
|
|
228
|
+
type: z.ZodEnum<{
|
|
229
|
+
内部Review: "内部Review";
|
|
230
|
+
客户阶段同步: "客户阶段同步";
|
|
231
|
+
Checkpoint: "Checkpoint";
|
|
232
|
+
}>;
|
|
233
|
+
change: z.ZodEnum<{
|
|
234
|
+
阶段推进: "阶段推进";
|
|
235
|
+
场景新增: "场景新增";
|
|
236
|
+
目标调整: "目标调整";
|
|
237
|
+
证据补充: "证据补充";
|
|
238
|
+
风险出现: "风险出现";
|
|
239
|
+
风险解除: "风险解除";
|
|
240
|
+
无实质进展: "无实质进展";
|
|
241
|
+
}>;
|
|
242
|
+
lines: z.ZodArray<z.ZodObject<{
|
|
243
|
+
plan_id: z.ZodOptional<z.ZodUnion<[z.ZodTemplateLiteral<`plan-${string}`>, z.ZodString]>>;
|
|
244
|
+
title: z.ZodString;
|
|
245
|
+
status: z.ZodEnum<{
|
|
246
|
+
未开始: "未开始";
|
|
247
|
+
取消: "取消";
|
|
248
|
+
进行中: "进行中";
|
|
249
|
+
已完成: "已完成";
|
|
250
|
+
延期: "延期";
|
|
251
|
+
}>;
|
|
252
|
+
actual: z.ZodString;
|
|
253
|
+
evidence: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
254
|
+
title: z.ZodString;
|
|
255
|
+
link: z.ZodOptional<z.ZodString>;
|
|
256
|
+
type: z.ZodOptional<z.ZodEnum<{
|
|
257
|
+
文档: "文档";
|
|
258
|
+
截图: "截图";
|
|
259
|
+
数据: "数据";
|
|
260
|
+
邮件: "邮件";
|
|
261
|
+
链接: "链接";
|
|
262
|
+
}>>;
|
|
263
|
+
}, z.core.$strict>>>;
|
|
264
|
+
customer: z.ZodOptional<z.ZodObject<{
|
|
265
|
+
synced_with: z.ZodOptional<z.ZodString>;
|
|
266
|
+
feedback: z.ZodOptional<z.ZodString>;
|
|
267
|
+
}, z.core.$strict>>;
|
|
268
|
+
scenario_ids: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
269
|
+
criteria_ids: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
270
|
+
completion: z.ZodOptional<z.ZodEnum<{
|
|
271
|
+
"0%": "0%";
|
|
272
|
+
"25%": "25%";
|
|
273
|
+
"50%": "50%";
|
|
274
|
+
"75%": "75%";
|
|
275
|
+
"100%": "100%";
|
|
276
|
+
}>>;
|
|
277
|
+
}, z.core.$strict>>;
|
|
278
|
+
next_plans: z.ZodArray<z.ZodObject<{
|
|
279
|
+
id: z.ZodTemplateLiteral<`plan-${string}`>;
|
|
280
|
+
goal: z.ZodString;
|
|
281
|
+
owner: z.ZodString;
|
|
282
|
+
deadline: z.ZodISODate;
|
|
283
|
+
}, z.core.$strict>>;
|
|
284
|
+
}, z.core.$strict>;
|
|
285
|
+
stage_notes: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
286
|
+
stage: z.ZodEnum<{
|
|
287
|
+
G0: "G0";
|
|
288
|
+
G1: "G1";
|
|
289
|
+
G2: "G2";
|
|
290
|
+
G4: "G4";
|
|
291
|
+
}>;
|
|
292
|
+
text: z.ZodString;
|
|
293
|
+
}, z.core.$strict>>>;
|
|
294
|
+
}, z.core.$strict>>;
|
|
295
|
+
format: z.ZodLiteral<"poc-report/1">;
|
|
296
|
+
ledger_version: z.ZodLiteral<"3.2">;
|
|
297
|
+
}, z.core.$strict>], "intent">;
|
|
298
|
+
export type Report = z.infer<typeof reportSchema>;
|
|
299
|
+
export type ReportRound = z.infer<typeof round>;
|
|
300
|
+
export type ReportLine = z.infer<typeof line>;
|
|
301
|
+
export declare function readReport(input: string): Report;
|
|
302
|
+
/** Stable by value rather than YAML formatting or key order; the real record is separate from the rendered subset. */
|
|
303
|
+
export declare function projectBase(project: PocRecord): string;
|
|
304
|
+
export declare function canonical(value: unknown): string;
|
|
305
|
+
export declare function lastRound(project: PocRecord): ProgressRecord | undefined;
|
|
306
|
+
export interface ReportPlan {
|
|
307
|
+
id: string;
|
|
308
|
+
goal: string;
|
|
309
|
+
owner: string;
|
|
310
|
+
deadline: string;
|
|
311
|
+
}
|
|
312
|
+
export declare function previousPlans(project: PocRecord): ReportPlan[];
|
|
313
|
+
/** Stable report-derived read data. Never treat colleague-reported status as a review verdict. */
|
|
314
|
+
export declare function structuredSummary(roundRecord: ProgressRecord): string;
|
|
315
|
+
export {};
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { createHash } from 'node:crypto';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
export const LEDGER_VERSION = '3.2';
|
|
4
|
+
export const REPORT_FORMAT = 'poc-report/1';
|
|
5
|
+
export const REPORT_DATA_ID = 'poc-return-data';
|
|
6
|
+
export const MAX_REPORT_BYTES = 4 * 1024 * 1024;
|
|
7
|
+
export const MAX_REPORT_PROJECTS = 200;
|
|
8
|
+
export const REPORT_ENUMS = {
|
|
9
|
+
type: ['内部Review', '客户阶段同步', 'Checkpoint'],
|
|
10
|
+
change: ['阶段推进', '场景新增', '目标调整', '证据补充', '风险出现', '风险解除', '无实质进展'],
|
|
11
|
+
status: ['已完成', '进行中', '未开始', '延期', '取消'],
|
|
12
|
+
evidence: ['文档', '截图', '数据', '邮件', '链接'],
|
|
13
|
+
completion: ['0%', '25%', '50%', '75%', '100%'],
|
|
14
|
+
system: ['人保体系', '国寿体系'],
|
|
15
|
+
poc_type: ['AI安全', '保护AI', 'ACG', 'SDL', '虚拟化', '大体量项目'],
|
|
16
|
+
risk: ['high', 'medium', 'low'],
|
|
17
|
+
};
|
|
18
|
+
const short = z.string().trim().min(1).max(500);
|
|
19
|
+
const narrative = z.string().trim().min(1).max(12_000);
|
|
20
|
+
const deadline = z.iso.date();
|
|
21
|
+
const uuid = z.uuid();
|
|
22
|
+
const newPlanId = z.templateLiteral(['plan-', uuid]);
|
|
23
|
+
const previousPlanId = newPlanId.or(z.string().regex(/^legacy-[1-9]\d*$/));
|
|
24
|
+
export const projectId = z.string().trim().max(64).regex(/^POC-[A-Z0-9]+(?:-[A-Z0-9]+)*$/, '项目编号须形如 POC-001 或 POC-2026-001');
|
|
25
|
+
const sha = z.string().regex(/^[a-f0-9]{64}$/);
|
|
26
|
+
const stageNotes = z.array(z.strictObject({ stage: z.enum(['G0', 'G1', 'G2', 'G4']), text: narrative })).max(4);
|
|
27
|
+
const identity = z.strictObject({
|
|
28
|
+
name: short, owner: short, company: short, tech_owner: short,
|
|
29
|
+
system: z.enum(REPORT_ENUMS.system).optional(), department: short.optional(), sales: short.optional(),
|
|
30
|
+
amount_wan: z.number().finite().nonnegative().optional(), poc_type: z.enum(REPORT_ENUMS.poc_type).optional(),
|
|
31
|
+
exec_sponsor: short.optional(),
|
|
32
|
+
});
|
|
33
|
+
const gate0 = z.strictObject({
|
|
34
|
+
why_customer: narrative, why_us: narrative, decision_chain: narrative, post_poc_decision: narrative,
|
|
35
|
+
competitor: short.optional(),
|
|
36
|
+
});
|
|
37
|
+
const line = z.strictObject({
|
|
38
|
+
plan_id: previousPlanId.optional(), title: short, status: z.enum(REPORT_ENUMS.status), actual: narrative,
|
|
39
|
+
evidence: z.array(z.strictObject({ title: short, link: z.string().trim().min(1).max(2_000).optional(), type: z.enum(REPORT_ENUMS.evidence).optional() })).max(30).optional(),
|
|
40
|
+
customer: z.strictObject({ synced_with: short.optional(), feedback: narrative.optional() }).optional(),
|
|
41
|
+
scenario_ids: z.array(z.string().regex(/^scn-\d{2,3}$/)).max(100).optional(),
|
|
42
|
+
criteria_ids: z.array(z.string().regex(/^cri-\d{2,3}$/)).max(100).optional(),
|
|
43
|
+
completion: z.enum(REPORT_ENUMS.completion).optional(),
|
|
44
|
+
});
|
|
45
|
+
const round = z.strictObject({
|
|
46
|
+
submission_id: uuid, date: deadline, type: z.enum(REPORT_ENUMS.type), change: z.enum(REPORT_ENUMS.change),
|
|
47
|
+
lines: z.array(line).max(100),
|
|
48
|
+
next_plans: z.array(z.strictObject({ id: newPlanId, goal: short, owner: short, deadline })).max(100),
|
|
49
|
+
});
|
|
50
|
+
const common = { format: z.literal(REPORT_FORMAT), ledger_version: z.literal(LEDGER_VERSION) };
|
|
51
|
+
export const reportSchema = z.discriminatedUnion('intent', [
|
|
52
|
+
z.strictObject({ ...common, intent: z.literal('new'), changes: z.tuple([z.strictObject({
|
|
53
|
+
poc_id: projectId, identity, gate0, round: round.optional(), stage_notes: stageNotes.optional(),
|
|
54
|
+
})]) }),
|
|
55
|
+
z.strictObject({ ...common, intent: z.literal('progress'), changes: z.array(z.strictObject({
|
|
56
|
+
poc_id: projectId, base: sha, round, stage_notes: stageNotes.optional(),
|
|
57
|
+
})).min(1).max(MAX_REPORT_PROJECTS) }),
|
|
58
|
+
]);
|
|
59
|
+
export function readReport(input) {
|
|
60
|
+
if (Buffer.byteLength(input, 'utf8') > MAX_REPORT_BYTES)
|
|
61
|
+
throw new Error('回执文件过大(上限 4 MiB)');
|
|
62
|
+
const source = input.trim();
|
|
63
|
+
let json = source;
|
|
64
|
+
if (!source.startsWith('{')) {
|
|
65
|
+
// Read only the exact inert data block emitted by the standalone generator.
|
|
66
|
+
// No DOM, no evaluation, no file paths or operations from the attachment.
|
|
67
|
+
const blocks = [...source.matchAll(/<script\s+type="application\/json"\s+id="poc-return-data"\s*>([^<]*)<\/script\s*>/gi)];
|
|
68
|
+
if (blocks.length !== 1)
|
|
69
|
+
throw new Error('未找到唯一的回传数据。请发送填写后「生成回传文件」下载的新版 HTML,不能发原始空白表单。');
|
|
70
|
+
json = blocks[0][1];
|
|
71
|
+
}
|
|
72
|
+
let data;
|
|
73
|
+
try {
|
|
74
|
+
data = JSON.parse(json);
|
|
75
|
+
}
|
|
76
|
+
catch {
|
|
77
|
+
throw new Error('回执数据不是有效 JSON');
|
|
78
|
+
}
|
|
79
|
+
const result = reportSchema.safeParse(data);
|
|
80
|
+
if (!result.success) {
|
|
81
|
+
const format = data && typeof data === 'object' && 'format' in data ? data.format : undefined;
|
|
82
|
+
if (format !== REPORT_FORMAT)
|
|
83
|
+
throw new Error('此回执不是 3.2 新回传格式;请重新导出,按上轮计划填写。');
|
|
84
|
+
throw new Error(result.error.issues.slice(0, 8).map((issue) => `${issue.path.join('.')}: ${issue.message}`).join('\n'));
|
|
85
|
+
}
|
|
86
|
+
return result.data;
|
|
87
|
+
}
|
|
88
|
+
/** Stable by value rather than YAML formatting or key order; the real record is separate from the rendered subset. */
|
|
89
|
+
export function projectBase(project) {
|
|
90
|
+
return createHash('sha256').update(canonical(project)).digest('hex');
|
|
91
|
+
}
|
|
92
|
+
export function canonical(value) {
|
|
93
|
+
return JSON.stringify(value, (_key, item) => {
|
|
94
|
+
if (!item || typeof item !== 'object' || Array.isArray(item))
|
|
95
|
+
return item;
|
|
96
|
+
return Object.fromEntries(Object.entries(item).sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0)));
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
export function lastRound(project) {
|
|
100
|
+
return Array.isArray(project.progress) ? project.progress.at(-1) ?? undefined : undefined;
|
|
101
|
+
}
|
|
102
|
+
export function previousPlans(project) {
|
|
103
|
+
const last = lastRound(project);
|
|
104
|
+
if (!last)
|
|
105
|
+
return [];
|
|
106
|
+
if (Array.isArray(last.next_plans))
|
|
107
|
+
return last.next_plans.flatMap((plan) => plan?.id && plan.goal
|
|
108
|
+
? [{ id: plan.id, goal: plan.goal, owner: plan.owner ?? '', deadline: plan.deadline ?? '' }] : []);
|
|
109
|
+
const goal = last.next?.goal?.trim();
|
|
110
|
+
if (!goal)
|
|
111
|
+
return [];
|
|
112
|
+
const position = project.progress?.length ?? 1;
|
|
113
|
+
const seq = Number.isSafeInteger(last.seq) && (last.seq ?? 0) > 0 ? last.seq : position;
|
|
114
|
+
return [{ id: `legacy-${seq}`, goal, owner: last.next?.owner ?? '', deadline: last.next?.deadline ?? '' }];
|
|
115
|
+
}
|
|
116
|
+
/** Stable report-derived read data. Never treat colleague-reported status as a review verdict. */
|
|
117
|
+
export function structuredSummary(roundRecord) {
|
|
118
|
+
return (roundRecord.lines ?? []).map((item) => `${item.title}(${item.status}):${item.actual}`).join('\n');
|
|
119
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { PocRecord } from './types.js';
|
|
2
|
+
export declare function buildReportHtml(intent: 'new' | 'progress', records: readonly PocRecord[], now?: Date): string;
|
|
3
|
+
export declare function reportFileName(intent: 'new' | 'progress', ids: readonly string[], now?: Date): string;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { randomUUID } from 'node:crypto';
|
|
2
|
+
import { lastRound, MAX_REPORT_PROJECTS, previousPlans, projectBase, projectId, REPORT_ENUMS } from './report-contract.js';
|
|
3
|
+
import { canReportProgress } from './progress.js';
|
|
4
|
+
import { REPORT_PAGE_SCRIPT } from './report-page.js';
|
|
5
|
+
import { REPORT_STYLE } from './report-style.js';
|
|
6
|
+
const scriptJSON = (value) => JSON.stringify(value)
|
|
7
|
+
.replace(/</g, '\\u003c').replace(/>/g, '\\u003e').replace(/\u2028/g, '\\u2028').replace(/\u2029/g, '\\u2029');
|
|
8
|
+
function calendarDate(now) {
|
|
9
|
+
const parts = new Intl.DateTimeFormat('en-CA', { timeZone: 'Asia/Shanghai', year: 'numeric', month: '2-digit', day: '2-digit' }).formatToParts(now);
|
|
10
|
+
return ['year', 'month', 'day'].map((kind) => parts.find((part) => part.type === kind)?.value).join('-');
|
|
11
|
+
}
|
|
12
|
+
export function buildReportHtml(intent, records, now = new Date()) {
|
|
13
|
+
if (records.length > MAX_REPORT_PROJECTS)
|
|
14
|
+
throw new Error(`最多可导出 ${MAX_REPORT_PROJECTS} 个项目`);
|
|
15
|
+
if (intent === 'progress') {
|
|
16
|
+
const closed = records.find((project) => !canReportProgress(project.stage, project.status));
|
|
17
|
+
if (closed)
|
|
18
|
+
throw new Error(`${closed.poc_id ?? ''} 已结束,不能导出记录进展表单`);
|
|
19
|
+
}
|
|
20
|
+
const title = intent === 'new' ? '新建项目 · POC 工作表' : '记录进展 · POC 工作表';
|
|
21
|
+
const projects = intent === 'new' ? [] : records.map((project) => ({
|
|
22
|
+
poc_id: projectId.parse(project.poc_id), name: project.name ?? '', stage: project.stage ?? '', status: project.status ?? '',
|
|
23
|
+
owner: project.owner ?? '', company: project.org?.company ?? '', base: projectBase(project),
|
|
24
|
+
previous_date: lastRound(project)?.date ?? '', round_count: project.progress?.length ?? 0,
|
|
25
|
+
previous_plans: previousPlans(project),
|
|
26
|
+
scenarios: (project.plan?.scenarios ?? []).flatMap((item) => item.id && /^scn-\d{2,3}$/.test(item.id) ? [{ id: item.id, name: item.name ?? item.id }] : []),
|
|
27
|
+
criteria: (project.plan?.criteria ?? []).flatMap((item) => item.id && /^cri-\d{2,3}$/.test(item.id) ? [{ id: item.id, name: item.name ?? item.id }] : []),
|
|
28
|
+
}));
|
|
29
|
+
return `<!doctype html>
|
|
30
|
+
<html lang="zh-CN"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1">
|
|
31
|
+
<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
|
+
<title>${title}</title><style>${REPORT_STYLE}</style></head><body>
|
|
33
|
+
<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>
|
|
35
|
+
<script>${REPORT_PAGE_SCRIPT.replace(/<\/script/gi, '<\\/script')}</script>
|
|
36
|
+
</body></html>`;
|
|
37
|
+
}
|
|
38
|
+
export function reportFileName(intent, ids, now = new Date()) {
|
|
39
|
+
const subject = intent === 'new' ? '新建项目' : ids.length === 1 && projectId.safeParse(ids[0]).success ? ids[0] : `${ids.length}个项目`;
|
|
40
|
+
return `poc-${intent}-${subject}-${calendarDate(now)}.html`;
|
|
41
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Report } from './report-contract.js';
|
|
2
|
+
export interface PreparedCandidate {
|
|
3
|
+
pocId: string;
|
|
4
|
+
action: 'create' | 'append' | 'unchanged';
|
|
5
|
+
seq?: number;
|
|
6
|
+
yaml?: string;
|
|
7
|
+
}
|
|
8
|
+
/** Pure, all-or-nothing planning. Do not call Git or write the user's ledger. */
|
|
9
|
+
export declare function prepareReport(input: Report, existing: ReadonlyMap<string, string>): PreparedCandidate[];
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import YAML from 'yaml';
|
|
2
|
+
import { canReportProgress } from './progress.js';
|
|
3
|
+
import { canonical, LEDGER_VERSION, previousPlans, projectBase, reportSchema } from './report-contract.js';
|
|
4
|
+
function requireUnique(values, what) {
|
|
5
|
+
if (new Set(values).size !== values.length)
|
|
6
|
+
throw new Error(`${what} 不可重复`);
|
|
7
|
+
}
|
|
8
|
+
function candidateRound(project, round, notes) {
|
|
9
|
+
const plans = previousPlans(project);
|
|
10
|
+
const byId = new Map(plans.map((p) => [p.id, p]));
|
|
11
|
+
const used = round.lines.flatMap((line) => line.plan_id ? [line.plan_id] : []);
|
|
12
|
+
requireUnique(used, '上轮计划的反馈');
|
|
13
|
+
for (const line of round.lines) {
|
|
14
|
+
if (line.plan_id && byId.get(line.plan_id)?.goal !== line.title)
|
|
15
|
+
throw new Error('反馈条目不匹配上轮计划编号或标题');
|
|
16
|
+
for (const [ids, available, name] of [
|
|
17
|
+
[line.scenario_ids, project.plan?.scenarios, '场景'], [line.criteria_ids, project.plan?.criteria, '指标'],
|
|
18
|
+
]) {
|
|
19
|
+
requireUnique(ids ?? [], `${line.title} 的${name}`);
|
|
20
|
+
for (const id of ids ?? []) {
|
|
21
|
+
if (!available?.some((item) => item.id === id))
|
|
22
|
+
throw new Error(`${line.title}:${name} ${id} 不存在`);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
if (used.length !== plans.length)
|
|
27
|
+
throw new Error('请逐项填写上轮计划,含未开始或取消的项目');
|
|
28
|
+
const oldPlanIds = (project.progress ?? []).flatMap((entry) => (entry.next_plans ?? []).map((p) => p.id));
|
|
29
|
+
requireUnique([...oldPlanIds, ...round.next_plans.map((plan) => plan.id)], '计划编号');
|
|
30
|
+
if (!round.lines.length && !round.next_plans.length && round.change !== '无实质进展') {
|
|
31
|
+
throw new Error('请填写一个进展或下一步计划;都没有时请选择「无实质进展」');
|
|
32
|
+
}
|
|
33
|
+
let max = 0;
|
|
34
|
+
for (const entry of project.progress ?? []) {
|
|
35
|
+
if (typeof entry.seq === 'number' && Number.isSafeInteger(entry.seq))
|
|
36
|
+
max = Math.max(max, entry.seq);
|
|
37
|
+
}
|
|
38
|
+
if (max >= Number.MAX_SAFE_INTEGER)
|
|
39
|
+
throw new Error('台账轮次编号超出可用范围');
|
|
40
|
+
const { lines, ...facts } = round;
|
|
41
|
+
return {
|
|
42
|
+
seq: max + 1, ...facts, ...(notes?.length ? { stage_notes: notes } : {}),
|
|
43
|
+
lines: lines.map((line) => ({
|
|
44
|
+
title: line.title, status: line.status, actual: line.actual,
|
|
45
|
+
...(line.plan_id ? { plan_id: line.plan_id } : {}),
|
|
46
|
+
...(line.evidence ? { evidence: line.evidence.map((entry) => ({ title: entry.title, link: entry.link ?? null, type: entry.type ?? null })) } : {}),
|
|
47
|
+
...(line.customer ? { customer: { ...(line.customer.synced_with ? { synced_with: line.customer.synced_with } : {}), ...(line.customer.feedback ? { feedback: line.customer.feedback } : {}) } } : {}),
|
|
48
|
+
...(line.scenario_ids ? { scenario_ids: line.scenario_ids } : {}),
|
|
49
|
+
...(line.criteria_ids ? { criteria_ids: line.criteria_ids } : {}),
|
|
50
|
+
...(line.completion ? { completion: line.completion } : {}),
|
|
51
|
+
})),
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
function sameSubmission(stored, round, notes) {
|
|
55
|
+
// A reviewer may have supplemented a line with a separate audit. It is not a
|
|
56
|
+
// member-submitted change and does not affect the replay comparison.
|
|
57
|
+
const { seq: _seq, stage_notes, lines, ...rest } = stored;
|
|
58
|
+
return canonical({ ...rest, lines: lines?.map(({ review: _review, evidence, ...facts }) => ({ ...facts, ...(evidence ? { evidence: evidence.map((entry) => ({ title: entry.title, ...(entry.link ? { link: entry.link } : {}), ...(entry.type ? { type: entry.type } : {}) })) } : {}) })), stage_notes: stage_notes ?? [] })
|
|
59
|
+
=== canonical({ ...round, stage_notes: notes ?? [] });
|
|
60
|
+
}
|
|
61
|
+
/** Pure, all-or-nothing planning. Do not call Git or write the user's ledger. */
|
|
62
|
+
export function prepareReport(input, existing) {
|
|
63
|
+
const report = reportSchema.parse(input);
|
|
64
|
+
requireUnique(report.changes.map((change) => change.poc_id), '项目编号');
|
|
65
|
+
requireUnique(report.changes.flatMap((change) => change.round ? [change.round.submission_id] : []), '回执编号');
|
|
66
|
+
if (report.intent === 'new') {
|
|
67
|
+
const change = report.changes[0];
|
|
68
|
+
const { poc_id: pocId, identity, gate0, round, stage_notes: notes } = change;
|
|
69
|
+
requireUnique((notes ?? []).map((note) => note.stage), '补充阶段');
|
|
70
|
+
if (notes?.length && !round)
|
|
71
|
+
throw new Error('保存阶段补充需随首轮进展记录');
|
|
72
|
+
const { company, system, department, name, owner, tech_owner, amount_wan, poc_type, sales, exec_sponsor } = identity;
|
|
73
|
+
const project = {
|
|
74
|
+
schema_version: LEDGER_VERSION, poc_id: pocId, name, owner, tech_owner,
|
|
75
|
+
amount_wan: amount_wan ?? null, poc_type: poc_type ?? null, sales: sales ?? null, exec_sponsor: exec_sponsor ?? null,
|
|
76
|
+
org: { company, system: system ?? null, department: department ?? null },
|
|
77
|
+
stage: 'G0-立项', status: '未开始',
|
|
78
|
+
gate0: { ...gate0, competitor: gate0.competitor ?? null }, plan: { scenarios: [], criteria: [], risks: [] }, progress: [], outcome: {},
|
|
79
|
+
};
|
|
80
|
+
if (existing.has(pocId))
|
|
81
|
+
throw new Error(`项目 ${pocId} 已存在,不能用新建回执覆盖`);
|
|
82
|
+
if (round)
|
|
83
|
+
project.progress.push(candidateRound(project, round, notes));
|
|
84
|
+
return [{ pocId, action: 'create', ...(round ? { seq: 1 } : {}), yaml: YAML.stringify(project) }];
|
|
85
|
+
}
|
|
86
|
+
return report.changes.map(({ poc_id: pocId, base, round, stage_notes: notes }) => {
|
|
87
|
+
requireUnique((notes ?? []).map((note) => note.stage), '补充阶段');
|
|
88
|
+
const source = existing.get(pocId);
|
|
89
|
+
if (!source)
|
|
90
|
+
throw new Error(`项目 ${pocId} 不存在,不能自动新建`);
|
|
91
|
+
const doc = YAML.parseDocument(source);
|
|
92
|
+
if (doc.errors.length)
|
|
93
|
+
throw new Error(`${pocId} 的台账 YAML 无法解析`);
|
|
94
|
+
const project = doc.toJS({ maxAliasCount: 50 });
|
|
95
|
+
if (!project || project.poc_id !== pocId)
|
|
96
|
+
throw new Error(`${pocId} 文件内编号不匹配`);
|
|
97
|
+
if (!Array.isArray(project.progress))
|
|
98
|
+
throw new Error(`${pocId} 的历史进展不是列表`);
|
|
99
|
+
if (project.schema_version !== LEDGER_VERSION)
|
|
100
|
+
throw new Error(`${pocId} 尚未迁移到台账 3.2,请先迁移再重新导出`);
|
|
101
|
+
const saved = project.progress.find((entry) => entry?.submission_id === round.submission_id);
|
|
102
|
+
if (saved) {
|
|
103
|
+
if (!sameSubmission(saved, round, notes))
|
|
104
|
+
throw new Error(`${pocId}:同一个回执编号已入账,但内容不同,不能重复提交`);
|
|
105
|
+
return { pocId, action: 'unchanged', ...(typeof saved.seq === 'number' ? { seq: saved.seq } : {}) };
|
|
106
|
+
}
|
|
107
|
+
if (projectBase(project) !== base)
|
|
108
|
+
throw new Error(`${pocId} 自导出后已有变更。请核对差异后重新导出,不能覆盖或把旧计划当成当前计划。`);
|
|
109
|
+
if (!canReportProgress(project.stage, project.status))
|
|
110
|
+
throw new Error(`${pocId} 已结束,不能追加进展`);
|
|
111
|
+
const entry = candidateRound(project, round, notes);
|
|
112
|
+
const list = doc.get('progress', true);
|
|
113
|
+
if (!YAML.isSeq(list))
|
|
114
|
+
throw new Error(`${pocId} 的进展不是可追加的 YAML 列表`);
|
|
115
|
+
list.add(doc.createNode(entry));
|
|
116
|
+
return { pocId, action: 'append', seq: entry.seq, yaml: doc.toString() };
|
|
117
|
+
});
|
|
118
|
+
}
|