@skillre/dsh-plugin-work-dashboard 0.11.1 → 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/compatibility.json +2 -2
- 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 +8 -12
- package/lib/client.js +74 -38
- package/lib/form.d.ts +144 -5
- package/lib/form.js +1439 -231
- 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 -82
- package/skills/poc-export/scripts/export-form.mjs +69 -624
- package/skills/poc-ledger/SKILL.md +14 -25
- package/skills/poc-submit/SKILL.md +13 -224
- package/skills/poc-submit/prepare-return.mjs +48 -0
package/lib/gap.d.ts
CHANGED
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
* the only writer of those fields, and a second implementation here would
|
|
22
22
|
* eventually disagree with CI.
|
|
23
23
|
*/
|
|
24
|
-
import type { GapItem, GapLevel, PocRecord, StageId } from './types.js';
|
|
24
|
+
import type { GapItem, GapLevel, PocRecord, ProgressRecord, StageId } from './types.js';
|
|
25
25
|
import { type RulesBundle } from './rules.js';
|
|
26
26
|
/** Normalize the free-form `stage` string onto a stage id. */
|
|
27
27
|
export declare function normalizeStage(raw: unknown): {
|
|
@@ -63,7 +63,7 @@ export declare function readDimensions(poc: PocRecord): {
|
|
|
63
63
|
nextMilestone: boolean;
|
|
64
64
|
};
|
|
65
65
|
/** The newest progress entry, or `null`. */
|
|
66
|
-
export declare function latestProgress(poc: PocRecord):
|
|
66
|
+
export declare function latestProgress(poc: PocRecord): ProgressRecord | null;
|
|
67
67
|
/** The newest progress date, or `null`. */
|
|
68
68
|
export declare function lastProgressDate(poc: PocRecord): string | null;
|
|
69
69
|
/** Whole days between a `YYYY-MM-DD` date and the scan clock. */
|
package/lib/gap.js
CHANGED
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
* the only writer of those fields, and a second implementation here would
|
|
22
22
|
* eventually disagree with CI.
|
|
23
23
|
*/
|
|
24
|
+
import { roundEvidence, structuredLines } from './progress.js';
|
|
24
25
|
import { FALLBACK_RULE_META, fallbackRules } from './rules.js';
|
|
25
26
|
/** Stage prefixes a raw `stage` value can normalize to, in order. */
|
|
26
27
|
const STAGE_PREFIXES = [
|
|
@@ -125,7 +126,7 @@ export function readDimensions(poc) {
|
|
|
125
126
|
// `outcome` is mostly auto-derived from the last progress entry, so a project
|
|
126
127
|
// that has progressed but not yet had its outcome summarised still counts:
|
|
127
128
|
// evidence exists when either the outcome or the newest entry carries it.
|
|
128
|
-
const lastEvidence =
|
|
129
|
+
const lastEvidence = roundEvidence(last);
|
|
129
130
|
return {
|
|
130
131
|
achievement: !blank(outcome.achievement),
|
|
131
132
|
evidence: !blank(outcome.our_proof) || lastEvidence.length > 0,
|
|
@@ -137,7 +138,7 @@ export function readDimensions(poc) {
|
|
|
137
138
|
export function latestProgress(poc) {
|
|
138
139
|
const progress = Array.isArray(poc.progress) ? poc.progress : [];
|
|
139
140
|
const last = progress.length === 0 ? null : progress[progress.length - 1];
|
|
140
|
-
return
|
|
141
|
+
return last ?? null;
|
|
141
142
|
}
|
|
142
143
|
/** The newest progress date, or `null`. */
|
|
143
144
|
export function lastProgressDate(poc) {
|
|
@@ -210,25 +211,31 @@ export function scanGaps(poc, options) {
|
|
|
210
211
|
}
|
|
211
212
|
// R7 — testing started before G2 was ready.
|
|
212
213
|
const ready = text(plan.gate2?.ready);
|
|
213
|
-
|
|
214
|
+
const hasTesting = progress.some((entry) => {
|
|
215
|
+
const lines = structuredLines(entry);
|
|
216
|
+
return lines === undefined || lines.some((line) => (line.scenario_ids?.length ?? 0) > 0 || (line.criteria_ids?.length ?? 0) > 0);
|
|
217
|
+
});
|
|
218
|
+
if (hasTesting && ready !== 'Ready') {
|
|
214
219
|
gaps.push(gap(poc, 'R7-g2-not-ready', { field: 'plan.gate2.ready', params: { ready: ready === '' ? '未设置' : ready } }));
|
|
215
220
|
}
|
|
216
221
|
// R8–R10 — the proof chain, judged by the NEWEST progress entry only.
|
|
217
222
|
if (last !== null) {
|
|
218
|
-
const
|
|
219
|
-
const
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
+
const lines = structuredLines(last);
|
|
224
|
+
const units = lines === undefined ? [{ actual: last.actual, evidence: last.evidence, review: {
|
|
225
|
+
recognition: last.customer?.recognition, gate3_1: last.gate3_1, gate3_2: last.gate3_2,
|
|
226
|
+
}, status: null }] : lines;
|
|
227
|
+
// Report one finding per rule per project. Each rule still checks each work
|
|
228
|
+
// item independently: a sibling's evidence cannot excuse a missing proof.
|
|
229
|
+
if (units.some((unit) => text(unit.actual) !== '' && !unit.evidence?.length && unit.status !== '未开始' && unit.status !== '取消')) {
|
|
223
230
|
gaps.push(gap(poc, 'R8-progress-no-evidence', { field: 'progress.evidence', params: { seq: numberOrNull(last.seq) ?? 0 } }));
|
|
224
231
|
}
|
|
225
|
-
|
|
226
|
-
if (
|
|
227
|
-
gaps.push(gap(poc, 'R9-evidence-no-recognition', { field: 'progress.customer.recognition', params: { recognition } }));
|
|
232
|
+
const pending = units.find((unit) => unit.evidence?.length && ['未认可', '待确认'].includes(text(unit.review?.recognition) || (lines ? '待确认' : '')));
|
|
233
|
+
if (pending) {
|
|
234
|
+
gaps.push(gap(poc, 'R9-evidence-no-recognition', { field: 'progress.customer.recognition', params: { recognition: text(pending.review?.recognition) || '待确认' } }));
|
|
228
235
|
}
|
|
229
|
-
|
|
230
|
-
if (
|
|
231
|
-
gaps.push(gap(poc, 'R10-g3-1-without-g3-2', { field: 'progress.gate3_2', params: { gate3_2: text(
|
|
236
|
+
const provable = units.find((unit) => unit.review?.gate3_1 === '可证明' && unit.review?.gate3_2 !== '已确认');
|
|
237
|
+
if (provable) {
|
|
238
|
+
gaps.push(gap(poc, 'R10-g3-1-without-g3-2', { field: 'progress.gate3_2', params: { gate3_2: text(provable.review?.gate3_2) || '未填' } }));
|
|
232
239
|
}
|
|
233
240
|
}
|
|
234
241
|
// R11 — achieved, and no next milestone: value created, none banked.
|
package/lib/index.js
CHANGED
|
@@ -19,7 +19,8 @@ import { RepoCache, RepoError, assertSafeCacheRoot } from './repo.js';
|
|
|
19
19
|
import { buildRiskBoard } from './risks.js';
|
|
20
20
|
import { buildGlobalTimeline } from './timeline.js';
|
|
21
21
|
import { text } from './gap.js';
|
|
22
|
-
import {
|
|
22
|
+
import { canReportProgress } from './progress.js';
|
|
23
|
+
import { buildReportHtml, reportFileName } from './report-form.js';
|
|
23
24
|
import { registerBundledSkills } from './skill.js';
|
|
24
25
|
import { createExecuteRoute } from './transport.js';
|
|
25
26
|
export { resolveConfig };
|
|
@@ -102,25 +103,23 @@ export function createRuntime(config, options = {}) {
|
|
|
102
103
|
* rather than an error, because a stale browser tab holding an id that was
|
|
103
104
|
* renamed in the ledger should still produce the projects it can.
|
|
104
105
|
*/
|
|
105
|
-
async exportForm(mode, pocIds
|
|
106
|
+
async exportForm(mode, pocIds) {
|
|
106
107
|
await this.prepare();
|
|
107
108
|
const stamp = now();
|
|
108
|
-
// Default from `mode` so an older Client bundle keeps working.
|
|
109
|
-
const resolved = intent ?? (mode === 'blank' ? 'new' : 'supplement');
|
|
110
109
|
if (mode === 'blank') {
|
|
111
|
-
return {
|
|
112
|
-
html: buildFormHtml({ mode: 'blank', intent: resolved, projects: [], now: stamp }),
|
|
113
|
-
fileName: formFileName({ mode: 'blank', pocIds: [], now: stamp }),
|
|
114
|
-
projectCount: 0,
|
|
115
|
-
};
|
|
110
|
+
return { html: buildReportHtml('new', [], stamp), fileName: reportFileName('new', [], stamp), projectCount: 0 };
|
|
116
111
|
}
|
|
117
112
|
const wanted = new Set(pocIds);
|
|
118
113
|
const records = (await loadOrEmpty()).filter((record) => wanted.has(text(record.poc_id)));
|
|
119
|
-
|
|
114
|
+
if (records.length === 0)
|
|
115
|
+
throw new RepoError('unknown-project', '没有匹配的项目,请刷新列表后重试。', {});
|
|
116
|
+
const ended = records.find((record) => !canReportProgress(record.stage, record.status));
|
|
117
|
+
if (ended)
|
|
118
|
+
throw new RepoError('unknown-project', `${text(ended.poc_id)} 已结束,不能导出记录进展表单。`, { pocId: text(ended.poc_id) });
|
|
120
119
|
return {
|
|
121
|
-
html:
|
|
122
|
-
fileName:
|
|
123
|
-
projectCount:
|
|
120
|
+
html: buildReportHtml('progress', records, stamp),
|
|
121
|
+
fileName: reportFileName('progress', records.map((record) => text(record.poc_id)), stamp),
|
|
122
|
+
projectCount: records.length,
|
|
124
123
|
};
|
|
125
124
|
},
|
|
126
125
|
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ProgressLineRecord, ProgressRecord, ProgressView } from './types.js';
|
|
2
|
+
/** Both export and import must agree which projects accept new progress. */
|
|
3
|
+
export declare function canReportProgress(stage: unknown, status: unknown): boolean;
|
|
4
|
+
export declare const structuredLines: (round: ProgressRecord | null | undefined) => ProgressLineRecord[] | undefined;
|
|
5
|
+
export declare const roundActual: (round: ProgressRecord) => string;
|
|
6
|
+
export declare const roundEvidence: (round: ProgressRecord | null | undefined) => import("./types.js").EvidenceRecord[];
|
|
7
|
+
/** Project one linked item at a time to retain evidence/review attribution in the scenario pane. */
|
|
8
|
+
export declare function scenarioRoundViews(view: ProgressView, scenarioId: string): ProgressView[];
|
package/lib/progress.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
const clean = (value) => typeof value === 'string' ? value.trim() : '';
|
|
2
|
+
/** Both export and import must agree which projects accept new progress. */
|
|
3
|
+
export function canReportProgress(stage, status) {
|
|
4
|
+
return clean(stage).toLowerCase() !== 'closed' && !['已关闭', '已取消'].includes(clean(status));
|
|
5
|
+
}
|
|
6
|
+
export const structuredLines = (round) => Array.isArray(round?.lines) ? round.lines.filter((item) => item && typeof item === 'object') : undefined;
|
|
7
|
+
export const roundActual = (round) => structuredLines(round)?.map((item) => `${clean(item.title)}(${clean(item.status)}):${clean(item.actual)}`).join('\n') ?? clean(round.actual);
|
|
8
|
+
export const roundEvidence = (round) => structuredLines(round)?.flatMap((line) => Array.isArray(line.evidence) ? line.evidence : []) ?? (Array.isArray(round?.evidence) ? round.evidence : []);
|
|
9
|
+
/** Project one linked item at a time to retain evidence/review attribution in the scenario pane. */
|
|
10
|
+
export function scenarioRoundViews(view, scenarioId) {
|
|
11
|
+
if (!view.lines)
|
|
12
|
+
return view.scenarioIds.includes(scenarioId) ? [view] : [];
|
|
13
|
+
return view.lines.filter((line) => line.scenario_ids?.includes(scenarioId)).map((line) => ({
|
|
14
|
+
...view, goal: clean(line.title), actual: clean(line.actual), completion: clean(line.completion),
|
|
15
|
+
scenarioIds: line.scenario_ids ?? [], criteriaIds: line.criteria_ids ?? [],
|
|
16
|
+
evidence: (line.evidence ?? []).map((item) => ({ title: clean(item.title), link: clean(item.link), type: clean(item.type) })),
|
|
17
|
+
customer: { syncedWith: clean(line.customer?.synced_with), feedback: clean(line.customer?.feedback), recognition: clean(line.review?.recognition) },
|
|
18
|
+
gate3_1: clean(line.review?.gate3_1), gate3_2: clean(line.review?.gate3_2),
|
|
19
|
+
}));
|
|
20
|
+
}
|
|
@@ -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
|
+
}
|