@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
|
@@ -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
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* POC 3.2 report page: the offline form a colleague edits, plus the read-only
|
|
3
|
+
* return receipt it produces.
|
|
4
|
+
*
|
|
5
|
+
* ## Contract
|
|
6
|
+
*
|
|
7
|
+
* The Host writes the shell and the data block; this module only supplies two
|
|
8
|
+
* strings:
|
|
9
|
+
*
|
|
10
|
+
* - `REPORT_STYLE` — embedded in a `<style>` element.
|
|
11
|
+
* - `REPORT_PAGE_SCRIPT` — embedded in a `<script>` element **after** the DOM
|
|
12
|
+
* nodes `<main id="app"></main>` and
|
|
13
|
+
* a `<script type="application/json" id="poc-report-input">` data block (with its
|
|
14
|
+
* matching closing tag) that carries the page payload.
|
|
15
|
+
*
|
|
16
|
+
* Everything else is built here. The page has to work from `file://` with no
|
|
17
|
+
* network, so there are no imports, no fonts, no images and no requests.
|
|
18
|
+
*
|
|
19
|
+
* ## Why the script is a function rendered through `toString()`
|
|
20
|
+
*
|
|
21
|
+
* The script is write-once plain JavaScript that runs inside the generated HTML
|
|
22
|
+
* page. If it were a template literal it would get no TypeScript checking at
|
|
23
|
+
* all — the first symptom of a typo would be a blank page on a colleague's
|
|
24
|
+
* laptop. So the browser code lives in `reportPage()`, a normal typed function,
|
|
25
|
+
* and is serialised with `Function.prototype.toString()`. Everything it needs is
|
|
26
|
+
* declared inside it: no module scope, no Host constants, no `Node` APIs.
|
|
27
|
+
*
|
|
28
|
+
* The generated return receipt is a self-contained HTML file. It repeats the
|
|
29
|
+
* payload in `<script type="application/json" id="poc-return-data">` (escaped,
|
|
30
|
+
* never executed) and lists the same facts as readable cards for a recipient
|
|
31
|
+
* who just double-clicks the file. The receipt carries no scripts beyond that
|
|
32
|
+
* inert JSON block.
|
|
33
|
+
*
|
|
34
|
+
* ## The payload (poc-report/1, ledger_version 3.2)
|
|
35
|
+
*
|
|
36
|
+
* `changes[]` is one entry per project the colleague actually filled in:
|
|
37
|
+
*
|
|
38
|
+
* - `new`: `{ poc_id, identity, gate0, stage_notes?, round? }`
|
|
39
|
+
* - `progress`: `{ poc_id, base, stage_notes?, round }`
|
|
40
|
+
*
|
|
41
|
+
* `round` is `{ submission_id, date, type, change, lines[], next_plans[] }`.
|
|
42
|
+
* Facts only: no `seq`, no Gate verdicts, no `review`. Execution state lives on
|
|
43
|
+
* each line and is not a result. Empty optional fields are omitted rather than
|
|
44
|
+
* sent as `null`, so "not answered" stays distinguishable from "answered empty".
|
|
45
|
+
*
|
|
46
|
+
* ## Host integration
|
|
47
|
+
*
|
|
48
|
+
* Drafts are stored under `poc-report-draft:<form_id>` and are discarded when
|
|
49
|
+
* the form's per-project `base` digests change, so a draft can never be applied
|
|
50
|
+
* on top of a different baseline.
|
|
51
|
+
*/
|
|
52
|
+
/**
|
|
53
|
+
* The page script, ready to embed inside a script element.
|
|
54
|
+
*
|
|
55
|
+
* `reportPage` is serialised rather than hand-written as a string so that
|
|
56
|
+
* TypeScript checks the browser code and a typo cannot silently ship as a blank
|
|
57
|
+
* page. The wrapper is an IIFE: the embedded script gets no globals, and the
|
|
58
|
+
* function's own `'use strict'` keeps accidental globals out.
|
|
59
|
+
*/
|
|
60
|
+
export declare const REPORT_PAGE_SCRIPT: string;
|