@skillre/dsh-plugin-work-dashboard 0.12.0 → 0.14.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 +9 -13
- package/lib/client.js +89 -48
- package/lib/form.js +118 -35
- package/lib/gap.d.ts +2 -2
- package/lib/gap.js +21 -14
- package/lib/index.js +26 -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 +25 -0
- package/lib/report-form.js +90 -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 +3217 -0
- package/lib/report-style.d.ts +18 -0
- package/lib/report-style.js +412 -0
- package/lib/store.js +8 -4
- package/lib/timeline.js +7 -6
- package/lib/types.d.ts +58 -9
- package/package.json +1 -1
- package/skills/poc-export/SKILL.md +10 -125
- package/skills/poc-export/scripts/export-form.mjs +34 -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
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, reportFileNames } from './report-form.js';
|
|
23
24
|
import { registerBundledSkills } from './skill.js';
|
|
24
25
|
import { createExecuteRoute } from './transport.js';
|
|
25
26
|
export { resolveConfig };
|
|
@@ -95,33 +96,45 @@ export function createRuntime(config, options = {}) {
|
|
|
95
96
|
return buildGlobalTimeline(await loadOrEmpty(), { stallDays: config.stallDays });
|
|
96
97
|
},
|
|
97
98
|
/**
|
|
98
|
-
* Build
|
|
99
|
+
* Build one collection form per project.
|
|
99
100
|
*
|
|
100
101
|
* `blank` is the new-project form and ignores the ids. `fill` selects the
|
|
101
102
|
* named projects; an id that matches nothing is simply absent from the form
|
|
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.
|
|
105
|
+
*
|
|
106
|
+
* Each project gets its own document: the export is handed to different
|
|
107
|
+
* owners, so a merged file would have to be split again before anyone could
|
|
108
|
+
* fill it in. Two projects that happen to share a name and an owner get a
|
|
109
|
+
* numeric suffix instead of overwriting each other in the download folder.
|
|
104
110
|
*/
|
|
105
|
-
async exportForm(mode, pocIds
|
|
111
|
+
async exportForm(mode, pocIds) {
|
|
106
112
|
await this.prepare();
|
|
107
113
|
const stamp = now();
|
|
108
|
-
// Default from `mode` so an older Client bundle keeps working.
|
|
109
|
-
const resolved = intent ?? (mode === 'blank' ? 'new' : 'supplement');
|
|
110
114
|
if (mode === 'blank') {
|
|
111
115
|
return {
|
|
112
|
-
|
|
113
|
-
|
|
116
|
+
files: [{ html: buildReportHtml('new', [], stamp), fileName: reportFileName('new', null, stamp), projectCount: 0, pocId: null }],
|
|
117
|
+
fileCount: 1,
|
|
114
118
|
projectCount: 0,
|
|
115
119
|
};
|
|
116
120
|
}
|
|
117
121
|
const wanted = new Set(pocIds);
|
|
118
122
|
const records = (await loadOrEmpty()).filter((record) => wanted.has(text(record.poc_id)));
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
123
|
+
if (records.length === 0)
|
|
124
|
+
throw new RepoError('unknown-project', '没有匹配的项目,请刷新列表后重试。', {});
|
|
125
|
+
const ended = records.find((record) => !canReportProgress(record.stage, record.status));
|
|
126
|
+
if (ended)
|
|
127
|
+
throw new RepoError('unknown-project', `${text(ended.poc_id)} 已结束,不能导出记录进展表单。`, { pocId: text(ended.poc_id) });
|
|
128
|
+
const names = reportFileNames('progress', records.map((record) => ({
|
|
129
|
+
name: text(record.name), owner: text(record.owner), pocId: text(record.poc_id),
|
|
130
|
+
})), stamp);
|
|
131
|
+
const files = records.map((record, index) => ({
|
|
132
|
+
html: buildReportHtml('progress', [record], stamp),
|
|
133
|
+
fileName: names[index] ?? '记录进展.html',
|
|
134
|
+
projectCount: 1,
|
|
135
|
+
pocId: text(record.poc_id),
|
|
136
|
+
}));
|
|
137
|
+
return { files, fileCount: files.length, projectCount: records.length };
|
|
125
138
|
},
|
|
126
139
|
};
|
|
127
140
|
}
|
|
@@ -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('未找到唯一的回传数据。请发送组员点「保存」后得到的表单文件,不能发原始空白表单。');
|
|
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,25 @@
|
|
|
1
|
+
import type { PocRecord } from './types.js';
|
|
2
|
+
export declare function buildReportHtml(intent: 'new' | 'progress', records: readonly PocRecord[], now?: Date): string;
|
|
3
|
+
/**
|
|
4
|
+
* The suggested download name for one form file.
|
|
5
|
+
*
|
|
6
|
+
* `项目名称_负责人` is the part the recipient reads in a chat list of files, so
|
|
7
|
+
* it comes first; the intent and the date make two exports of the same project
|
|
8
|
+
* distinguishable without opening either.
|
|
9
|
+
*/
|
|
10
|
+
export declare function reportFileName(intent: 'new' | 'progress', project: {
|
|
11
|
+
name?: string;
|
|
12
|
+
owner?: string;
|
|
13
|
+
pocId?: string;
|
|
14
|
+
} | null, now?: Date): string;
|
|
15
|
+
/**
|
|
16
|
+
* One download name per project, made unique inside this batch.
|
|
17
|
+
*
|
|
18
|
+
* Two projects may legitimately share a name and an owner; without a suffix the
|
|
19
|
+
* second download would silently replace the first in the recipient's folder.
|
|
20
|
+
*/
|
|
21
|
+
export declare function reportFileNames(intent: 'new' | 'progress', projects: readonly {
|
|
22
|
+
name?: string;
|
|
23
|
+
owner?: string;
|
|
24
|
+
pocId?: string;
|
|
25
|
+
}[], now?: Date): string[];
|