@skillre/dsh-plugin-work-dashboard 0.6.0 → 0.9.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 +12 -6
- package/README.md +32 -8
- package/compatibility.json +44 -4
- package/docs/PLAN-0.7-0.9.md +230 -0
- package/lib/blockers.d.ts +45 -0
- package/lib/blockers.js +160 -0
- package/lib/client/api.d.ts +8 -1
- package/lib/client/api.js +1 -0
- package/lib/client/css/base.d.ts +1 -1
- package/lib/client/css/base.js +39 -0
- package/lib/client/css/blockers.d.ts +18 -0
- package/lib/client/css/blockers.js +196 -0
- package/lib/client/css/detail.d.ts +1 -1
- package/lib/client/css/detail.js +24 -0
- package/lib/client/css/overview.d.ts +5 -4
- package/lib/client/css/overview.js +23 -34
- package/lib/client/css/summary.d.ts +13 -0
- package/lib/client/css/summary.js +187 -0
- package/lib/client/format.d.ts +57 -0
- package/lib/client/format.js +96 -0
- package/lib/client/styles.js +3 -1
- package/lib/client/text.js +216 -38
- package/lib/client/view-contract.d.ts +9 -1
- package/lib/client.js +2104 -894
- package/lib/form.d.ts +218 -0
- package/lib/form.js +1075 -0
- package/lib/index.js +29 -0
- package/lib/store.js +13 -2
- package/lib/transport.d.ts +7 -1
- package/lib/transport.js +10 -0
- package/lib/types.d.ts +89 -0
- package/lib/types.js +16 -0
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -18,6 +18,8 @@ import { PocStore } from './store.js';
|
|
|
18
18
|
import { RepoCache, RepoError, assertSafeCacheRoot } from './repo.js';
|
|
19
19
|
import { buildRiskBoard } from './risks.js';
|
|
20
20
|
import { buildGlobalTimeline } from './timeline.js';
|
|
21
|
+
import { text } from './gap.js';
|
|
22
|
+
import { buildFormHtml, formFileName, projectForForm } from './form.js';
|
|
21
23
|
import { registerBundledSkills } from './skill.js';
|
|
22
24
|
import { createExecuteRoute } from './transport.js';
|
|
23
25
|
export { resolveConfig };
|
|
@@ -92,6 +94,33 @@ export function createRuntime(config, options = {}) {
|
|
|
92
94
|
await this.prepare();
|
|
93
95
|
return buildGlobalTimeline(await loadOrEmpty(), { stallDays: config.stallDays });
|
|
94
96
|
},
|
|
97
|
+
/**
|
|
98
|
+
* Build the collection form.
|
|
99
|
+
*
|
|
100
|
+
* `blank` is the new-project form and ignores the ids. `fill` selects the
|
|
101
|
+
* named projects; an id that matches nothing is simply absent from the form
|
|
102
|
+
* rather than an error, because a stale browser tab holding an id that was
|
|
103
|
+
* renamed in the ledger should still produce the projects it can.
|
|
104
|
+
*/
|
|
105
|
+
async exportForm(mode, pocIds) {
|
|
106
|
+
await this.prepare();
|
|
107
|
+
const stamp = now();
|
|
108
|
+
if (mode === 'blank') {
|
|
109
|
+
return {
|
|
110
|
+
html: buildFormHtml({ mode: 'blank', projects: [], now: stamp }),
|
|
111
|
+
fileName: formFileName({ mode: 'blank', pocIds: [], now: stamp }),
|
|
112
|
+
projectCount: 0,
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
const wanted = new Set(pocIds);
|
|
116
|
+
const records = (await loadOrEmpty()).filter((record) => wanted.has(text(record.poc_id)));
|
|
117
|
+
const projects = records.map(projectForForm);
|
|
118
|
+
return {
|
|
119
|
+
html: buildFormHtml({ mode: 'fill', projects, now: stamp }),
|
|
120
|
+
fileName: formFileName({ mode: 'fill', pocIds: records.map((record) => text(record.poc_id)), now: stamp }),
|
|
121
|
+
projectCount: projects.length,
|
|
122
|
+
};
|
|
123
|
+
},
|
|
95
124
|
};
|
|
96
125
|
}
|
|
97
126
|
export function apply(ctx, rawConfig = {}) {
|
package/lib/store.js
CHANGED
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
*/
|
|
17
17
|
import YAML from 'yaml';
|
|
18
18
|
import { daysSince, lastProgressDate, latestProgress, normalizeStage, numberOrNull, readDimensions, scanGaps, text, } from './gap.js';
|
|
19
|
+
import { buildBlockerBoard } from './blockers.js';
|
|
19
20
|
import { RepoError } from './repo.js';
|
|
20
21
|
/** The Host-side view model builder. */
|
|
21
22
|
export class PocStore {
|
|
@@ -88,6 +89,7 @@ export class PocStore {
|
|
|
88
89
|
stats: emptyStats(),
|
|
89
90
|
gaps: [],
|
|
90
91
|
analysis: emptyAnalysis(),
|
|
92
|
+
blockers: buildBlockerBoard([], { now: this.options.now(), stallDays: this.options.stallDays }),
|
|
91
93
|
warnings: [],
|
|
92
94
|
};
|
|
93
95
|
}
|
|
@@ -109,6 +111,7 @@ export class PocStore {
|
|
|
109
111
|
stats: computeStats(sorted),
|
|
110
112
|
gaps,
|
|
111
113
|
analysis: analyse(sorted, gaps),
|
|
114
|
+
blockers: buildBlockerBoard(records, { now, stallDays: this.options.stallDays }),
|
|
112
115
|
warnings,
|
|
113
116
|
};
|
|
114
117
|
}
|
|
@@ -294,6 +297,12 @@ function summarize(record, now, stallDays) {
|
|
|
294
297
|
daysSinceProgress: daysSince(activity, now),
|
|
295
298
|
outcomeAchievement: text((record.outcome ?? {}).achievement),
|
|
296
299
|
outcomeRecognition: text((record.outcome ?? {}).customer_recognition),
|
|
300
|
+
// Read from the NEWEST progress entry, not from `outcome`: the outcome block
|
|
301
|
+
// is written later by hand, and "waiting on the customer" is a statement
|
|
302
|
+
// about the last round that actually happened.
|
|
303
|
+
lastRecognition: last === null
|
|
304
|
+
? ''
|
|
305
|
+
: text(last.customer?.recognition),
|
|
297
306
|
};
|
|
298
307
|
}
|
|
299
308
|
/**
|
|
@@ -304,7 +313,6 @@ function summarize(record, now, stallDays) {
|
|
|
304
313
|
*/
|
|
305
314
|
function computeStats(projects) {
|
|
306
315
|
let amountTotalWan = 0;
|
|
307
|
-
let awaitingCustomer = 0;
|
|
308
316
|
for (const project of projects) {
|
|
309
317
|
amountTotalWan += project.amountWan;
|
|
310
318
|
}
|
|
@@ -314,7 +322,10 @@ function computeStats(projects) {
|
|
|
314
322
|
inProgress: projects.filter((project) => project.status === '进行中').length,
|
|
315
323
|
amountTotalWan,
|
|
316
324
|
g0Complete: projects.filter((project) => project.g0Complete).length,
|
|
317
|
-
|
|
325
|
+
// "Awaiting customer" = the newest progress entry says the customer has not
|
|
326
|
+
// signed off yet. It used to be a `let` that was never incremented, so the
|
|
327
|
+
// counter was hard-wired to 0 while the KPI strip displayed it.
|
|
328
|
+
awaitingCustomer: projects.filter((project) => project.lastRecognition === '待确认' || project.lastRecognition === '部分认可').length,
|
|
318
329
|
succeeded: projects.filter((project) => project.outcomeAchievement === '达成' && project.outcomeRecognition === '认可').length,
|
|
319
330
|
stopped: projects.filter((project) => project.status === '暂停' || project.status === '已关闭' || project.status === '已取消').length,
|
|
320
331
|
};
|
package/lib/transport.d.ts
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
* `{ type: 'server-response', rpcId, result: { ok: true, value } | { ok: false, error } }`
|
|
12
12
|
* out. A non-owner Peer is rejected by Connection before this handler runs.
|
|
13
13
|
*/
|
|
14
|
-
import type { GlobalTimeline, ProjectDetail, RefreshOutcome, RiskBoard, Snapshot } from './types.js';
|
|
14
|
+
import type { ExportFormResult, GlobalTimeline, ProjectDetail, RefreshOutcome, RiskBoard, Snapshot } from './types.js';
|
|
15
15
|
/** Path of the exact route, under the shared `/api` channel. */
|
|
16
16
|
export declare const EXECUTE_PATH = "/api/skillre-work-dashboard/execute";
|
|
17
17
|
/** One buffered exact Fetch route as the Connection registry accepts it. */
|
|
@@ -42,6 +42,12 @@ export interface ConsoleActions {
|
|
|
42
42
|
risks(): Promise<RiskBoard>;
|
|
43
43
|
/** Every project's rounds, newest first. */
|
|
44
44
|
timeline(): Promise<GlobalTimeline>;
|
|
45
|
+
/**
|
|
46
|
+
* Build the collection form for one batch.
|
|
47
|
+
*
|
|
48
|
+
* `blank` ignores `pocIds` and returns the new-project form.
|
|
49
|
+
*/
|
|
50
|
+
exportForm(mode: 'fill' | 'blank', pocIds: readonly string[]): Promise<ExportFormResult>;
|
|
45
51
|
}
|
|
46
52
|
/**
|
|
47
53
|
* Build the exact route Connection registers; every failure stays inside the
|
package/lib/transport.js
CHANGED
|
@@ -30,6 +30,14 @@ const requestSchema = z.discriminatedUnion('action', [
|
|
|
30
30
|
z.object({ action: z.literal('detail'), pocId: pocIdSchema }).strict(),
|
|
31
31
|
z.object({ action: z.literal('risks') }).strict(),
|
|
32
32
|
z.object({ action: z.literal('timeline') }).strict(),
|
|
33
|
+
z.object({
|
|
34
|
+
action: z.literal('export-form'),
|
|
35
|
+
mode: z.union([z.literal('fill'), z.literal('blank')]),
|
|
36
|
+
// Bounded: a form is meant for a batch a colleague will actually fill in,
|
|
37
|
+
// and an unbounded list would let one request build a thousands-project
|
|
38
|
+
// document on the Host.
|
|
39
|
+
pocIds: z.array(pocIdSchema).max(200),
|
|
40
|
+
}).strict(),
|
|
33
41
|
]);
|
|
34
42
|
/** A JSON response with no-store caching; the board is always live state. */
|
|
35
43
|
function json(body, status = 200) {
|
|
@@ -68,6 +76,8 @@ async function dispatch(actions, request, signal) {
|
|
|
68
76
|
return actions.risks();
|
|
69
77
|
case 'timeline':
|
|
70
78
|
return actions.timeline();
|
|
79
|
+
case 'export-form':
|
|
80
|
+
return actions.exportForm(request.mode, request.pocIds);
|
|
71
81
|
}
|
|
72
82
|
}
|
|
73
83
|
export function createExecuteRoute(ready, options = {}) {
|
package/lib/types.d.ts
CHANGED
|
@@ -257,6 +257,15 @@ export interface ProjectSummary {
|
|
|
257
257
|
outcomeAchievement: string;
|
|
258
258
|
/** Raw `outcome.customer_recognition`; `''` when unset. */
|
|
259
259
|
outcomeRecognition: string;
|
|
260
|
+
/**
|
|
261
|
+
* The newest progress entry's `customer.recognition`, or `''`.
|
|
262
|
+
*
|
|
263
|
+
* Distinct from {@link outcomeRecognition}: `outcome` is often filled in later
|
|
264
|
+
* by hand, while this is what the customer said in the last recorded round.
|
|
265
|
+
* "Waiting on the customer" is a statement about the newest round, so the
|
|
266
|
+
* counter reads this one.
|
|
267
|
+
*/
|
|
268
|
+
lastRecognition: string;
|
|
260
269
|
}
|
|
261
270
|
/** One gap finding, addressed to a project and a rule. */
|
|
262
271
|
export interface GapItem {
|
|
@@ -391,6 +400,14 @@ export interface Snapshot {
|
|
|
391
400
|
gaps: GapItem[];
|
|
392
401
|
/** Aggregated portfolio view; empty buckets when there are no projects. */
|
|
393
402
|
analysis: PortfolioAnalysis;
|
|
403
|
+
/**
|
|
404
|
+
* Every reason a project is stuck, merged from the five sources.
|
|
405
|
+
*
|
|
406
|
+
* Shipped WITH the snapshot rather than behind its own endpoint: the board is
|
|
407
|
+
* derived from the same records the list shows, so two requests could
|
|
408
|
+
* disagree after a refresh, and the Client already holds the whole snapshot.
|
|
409
|
+
*/
|
|
410
|
+
blockers: BlockerBoard;
|
|
394
411
|
/** Non-fatal findings: unreadable files, unparsable YAML, duplicates. */
|
|
395
412
|
warnings: string[];
|
|
396
413
|
}
|
|
@@ -526,7 +543,79 @@ export type PocRequest = {
|
|
|
526
543
|
action: 'risks';
|
|
527
544
|
} | {
|
|
528
545
|
action: 'timeline';
|
|
546
|
+
} | {
|
|
547
|
+
action: 'export-form';
|
|
548
|
+
mode: 'fill' | 'blank';
|
|
549
|
+
pocIds: string[];
|
|
529
550
|
};
|
|
551
|
+
/**
|
|
552
|
+
* One generated collection form, ready for the browser to save.
|
|
553
|
+
*
|
|
554
|
+
* The HTML is generated on the Host rather than in the Client because the
|
|
555
|
+
* generator needs the YAML serializer, and bundling `yaml` into the browser
|
|
556
|
+
* module would add ~100 KiB to a page that never otherwise parses YAML.
|
|
557
|
+
*/
|
|
558
|
+
export interface ExportFormResult {
|
|
559
|
+
/** The whole self-contained document. */
|
|
560
|
+
html: string;
|
|
561
|
+
/** The suggested download name. */
|
|
562
|
+
fileName: string;
|
|
563
|
+
/** How many projects the form covers; `0` for a blank form. */
|
|
564
|
+
projectCount: number;
|
|
565
|
+
}
|
|
566
|
+
/**
|
|
567
|
+
* Where a blocker comes from.
|
|
568
|
+
*
|
|
569
|
+
* The five sources are one user-facing idea — "where is this stuck" — but they
|
|
570
|
+
* are NOT the same kind of finding: a gap is a judgement about the ledger's
|
|
571
|
+
* content, while a missing amount is a data-completeness issue. Keeping the
|
|
572
|
+
* source on the row is what lets the UI filter and explain them without the
|
|
573
|
+
* reader having to know which subsystem produced them.
|
|
574
|
+
*/
|
|
575
|
+
export declare const BLOCKER_SOURCES: readonly ["gap", "stalled", "missing-amount", "no-progress", "no-stage-since"];
|
|
576
|
+
export type BlockerSource = (typeof BLOCKER_SOURCES)[number];
|
|
577
|
+
/** One blocker row: a project, a reason, and a source. */
|
|
578
|
+
export interface BlockerRow {
|
|
579
|
+
/** Which subsystem found it. */
|
|
580
|
+
source: BlockerSource;
|
|
581
|
+
/** `high` blocks progress, `medium` is a warning. */
|
|
582
|
+
level: GapLevel;
|
|
583
|
+
/** Sort weight: higher is more urgent. */
|
|
584
|
+
priority: number;
|
|
585
|
+
pocId: string;
|
|
586
|
+
pocName: string;
|
|
587
|
+
/** The state the project is in, for context: `G0-立项`, `closed`, or `''`. */
|
|
588
|
+
stageLabel: string;
|
|
589
|
+
/**
|
|
590
|
+
* The gap rule that produced this row, when `source === 'gap'`.
|
|
591
|
+
*
|
|
592
|
+
* `null` for the four non-gap sources: they are not rules, and pretending
|
|
593
|
+
* they are would make the rule-numbered badge lie.
|
|
594
|
+
*/
|
|
595
|
+
rule: GapRule | null;
|
|
596
|
+
/** Rule number, or `0` for a non-gap source. */
|
|
597
|
+
ruleNo: number;
|
|
598
|
+
/** Rule-specific values the Client interpolates into its copy. */
|
|
599
|
+
params: Record<string, number | string>;
|
|
600
|
+
}
|
|
601
|
+
/** The unified blocker list plus its per-source counts. */
|
|
602
|
+
export interface BlockerBoard {
|
|
603
|
+
/** Every blocker, most urgent first. */
|
|
604
|
+
rows: BlockerRow[];
|
|
605
|
+
/** Per-source totals, so the UI can offer a count per filter chip. */
|
|
606
|
+
counts: Record<BlockerSource, number>;
|
|
607
|
+
/** Projects carrying at least one blocker. */
|
|
608
|
+
projectsBlocked: number;
|
|
609
|
+
/** Projects scanned, so the board can say "3 of 30". */
|
|
610
|
+
projectsTotal: number;
|
|
611
|
+
}
|
|
612
|
+
/** The five G0 prerequisites, as the worklist names them. */
|
|
613
|
+
export interface Gate0WorkItem {
|
|
614
|
+
/** The YAML field name. */
|
|
615
|
+
field: string;
|
|
616
|
+
/** `true` when the field carries content. */
|
|
617
|
+
present: boolean;
|
|
618
|
+
}
|
|
530
619
|
/** One risk row on the risk board. */
|
|
531
620
|
export interface RiskRow {
|
|
532
621
|
pocId: string;
|
package/lib/types.js
CHANGED
|
@@ -60,3 +60,19 @@ export const GAP_RULES = Object.freeze([
|
|
|
60
60
|
'R11-no-next-milestone',
|
|
61
61
|
'R12-stage-stalled',
|
|
62
62
|
]);
|
|
63
|
+
/**
|
|
64
|
+
* Where a blocker comes from.
|
|
65
|
+
*
|
|
66
|
+
* The five sources are one user-facing idea — "where is this stuck" — but they
|
|
67
|
+
* are NOT the same kind of finding: a gap is a judgement about the ledger's
|
|
68
|
+
* content, while a missing amount is a data-completeness issue. Keeping the
|
|
69
|
+
* source on the row is what lets the UI filter and explain them without the
|
|
70
|
+
* reader having to know which subsystem produced them.
|
|
71
|
+
*/
|
|
72
|
+
export const BLOCKER_SOURCES = Object.freeze([
|
|
73
|
+
'gap',
|
|
74
|
+
'stalled',
|
|
75
|
+
'missing-amount',
|
|
76
|
+
'no-progress',
|
|
77
|
+
'no-stage-since',
|
|
78
|
+
]);
|