@skillre/dsh-plugin-work-dashboard 0.0.0-stage → 0.6.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/LICENSE +21 -0
- package/README.en.md +253 -0
- package/README.md +347 -2
- package/UNINSTALL.md +7 -0
- package/compatibility.json +155 -0
- package/cordis.patch.yml +24 -0
- package/docs/DESIGN-0.3.md +122 -0
- package/docs/DETAIL.md +1 -0
- package/docs/DETAIL.zh.md +1 -0
- package/docs/preview.svg +254 -0
- package/docs/preview.zh.svg +254 -0
- package/icon.svg +17 -0
- package/lib/client/api.d.ts +35 -0
- package/lib/client/api.js +44 -0
- package/lib/client/contracts.d.ts +94 -0
- package/lib/client/contracts.js +21 -0
- package/lib/client/css/base.d.ts +31 -0
- package/lib/client/css/base.js +422 -0
- package/lib/client/css/charts.d.ts +14 -0
- package/lib/client/css/charts.js +191 -0
- package/lib/client/css/detail.d.ts +21 -0
- package/lib/client/css/detail.js +399 -0
- package/lib/client/css/insights.d.ts +27 -0
- package/lib/client/css/insights.js +660 -0
- package/lib/client/css/overview.d.ts +22 -0
- package/lib/client/css/overview.js +338 -0
- package/lib/client/preferences.d.ts +56 -0
- package/lib/client/preferences.js +118 -0
- package/lib/client/styles.d.ts +17 -0
- package/lib/client/styles.js +22 -0
- package/lib/client/text.d.ts +32 -0
- package/lib/client/text.js +934 -0
- package/lib/client/view-contract.d.ts +110 -0
- package/lib/client/view-contract.js +28 -0
- package/lib/client.js +5389 -0
- package/lib/config.d.ts +61 -0
- package/lib/config.js +67 -0
- package/lib/gap.d.ts +60 -0
- package/lib/gap.js +227 -0
- package/lib/index.d.ts +40 -0
- package/lib/index.js +130 -0
- package/lib/repo.d.ts +124 -0
- package/lib/repo.js +407 -0
- package/lib/risks.d.ts +24 -0
- package/lib/risks.js +85 -0
- package/lib/skill.d.ts +94 -0
- package/lib/skill.js +220 -0
- package/lib/store.d.ts +63 -0
- package/lib/store.js +494 -0
- package/lib/timeline.d.ts +23 -0
- package/lib/timeline.js +93 -0
- package/lib/transport.d.ts +61 -0
- package/lib/transport.js +121 -0
- package/lib/types.d.ts +612 -0
- package/lib/types.js +62 -0
- package/locale/en.json +7 -0
- package/locale/zh.json +7 -0
- package/package.json +117 -4
- package/skills/poc-export/SKILL.md +81 -0
- package/skills/poc-export/scripts/export-form.mjs +654 -0
- package/skills/poc-ledger/SKILL.md +171 -0
- package/skills/poc-submit/SKILL.md +186 -0
package/lib/config.d.ts
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Plugin configuration.
|
|
3
|
+
*
|
|
4
|
+
* Schemastery is the loader-facing schema: DSH resolves a row's `config`
|
|
5
|
+
* through it before `apply` runs, so every tunable value has a declared
|
|
6
|
+
* default and an out-of-range value fails loudly at mount time instead of
|
|
7
|
+
* silently cloning into the wrong directory.
|
|
8
|
+
*/
|
|
9
|
+
import Schema from '@deepseek-ai/schemastery';
|
|
10
|
+
/** Effective plugin configuration after schema resolution. */
|
|
11
|
+
export interface WorkDashboardConfig {
|
|
12
|
+
/** Data source, as `owner/name` on GitHub. */
|
|
13
|
+
repository: string;
|
|
14
|
+
/**
|
|
15
|
+
* Clone URL override.
|
|
16
|
+
*
|
|
17
|
+
* Empty means the canonical `https://github.com/<repository>.git`. It exists
|
|
18
|
+
* for three real cases: a GitHub Enterprise host, a mirror, and a local test
|
|
19
|
+
* remote (which is how the submission path is verified without pushing to
|
|
20
|
+
* anyone's real repository).
|
|
21
|
+
*/
|
|
22
|
+
remoteUrl: string;
|
|
23
|
+
/** Cache root wiped at mount and recreated on demand. `~` is expanded. */
|
|
24
|
+
cacheRoot: string;
|
|
25
|
+
/** Branch tracked by the clone. */
|
|
26
|
+
defaultBranch: string;
|
|
27
|
+
/**
|
|
28
|
+
* Hard ceiling for one `git clone`, in milliseconds.
|
|
29
|
+
*
|
|
30
|
+
* Measured on this network: a normal clone of the ledger takes ~1.5s, but a
|
|
31
|
+
* congested one has taken 68s. The default is therefore generous; a timeout
|
|
32
|
+
* still fails with a clear reason and a retry button.
|
|
33
|
+
*/
|
|
34
|
+
cloneTimeoutMs: number;
|
|
35
|
+
/** Hard ceiling for one `git fetch` + `reset --hard`, in milliseconds. */
|
|
36
|
+
fetchTimeoutMs: number;
|
|
37
|
+
/** Days in one stage after which rule 12 reports the project as stalled. */
|
|
38
|
+
stallDays: number;
|
|
39
|
+
}
|
|
40
|
+
/** Default cache root, under the DSH home so a system cleaner never eats it. */
|
|
41
|
+
export declare const DEFAULT_CACHE_ROOT = "~/.dsh/cache/work-dashboard";
|
|
42
|
+
/** The schema DSH resolves a `skillre-work-dashboard` row's config through. */
|
|
43
|
+
export declare const Config: Schema<WorkDashboardConfig>;
|
|
44
|
+
/**
|
|
45
|
+
* Resolve raw row config, keeping the declared defaults authoritative.
|
|
46
|
+
*
|
|
47
|
+
* The shape checks that Schemastery cannot express (a repository is
|
|
48
|
+
* `owner/name`, a branch has no ref-spec metacharacters) run here so a typo
|
|
49
|
+
* fails at mount with a readable message instead of as a git exit code later.
|
|
50
|
+
*/
|
|
51
|
+
export declare function resolveConfig(raw?: unknown): WorkDashboardConfig;
|
|
52
|
+
/**
|
|
53
|
+
* Expand a leading `~` to the current user's home directory.
|
|
54
|
+
*
|
|
55
|
+
* Kept out of {@link resolveConfig} so the resolved config stays a faithful
|
|
56
|
+
* echo of what the profile declared, and every filesystem use expands at the
|
|
57
|
+
* point of use instead.
|
|
58
|
+
*/
|
|
59
|
+
/** The clone URL for the configured source, honoring the `remoteUrl` override. */
|
|
60
|
+
export declare function remoteUrlFor(config: WorkDashboardConfig): string;
|
|
61
|
+
export declare function expandHome(path: string, home: string): string;
|
package/lib/config.js
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Plugin configuration.
|
|
3
|
+
*
|
|
4
|
+
* Schemastery is the loader-facing schema: DSH resolves a row's `config`
|
|
5
|
+
* through it before `apply` runs, so every tunable value has a declared
|
|
6
|
+
* default and an out-of-range value fails loudly at mount time instead of
|
|
7
|
+
* silently cloning into the wrong directory.
|
|
8
|
+
*/
|
|
9
|
+
import Schema from '@deepseek-ai/schemastery';
|
|
10
|
+
/** Default cache root, under the DSH home so a system cleaner never eats it. */
|
|
11
|
+
export const DEFAULT_CACHE_ROOT = '~/.dsh/cache/work-dashboard';
|
|
12
|
+
/** The schema DSH resolves a `skillre-work-dashboard` row's config through. */
|
|
13
|
+
export const Config = Schema.object({
|
|
14
|
+
repository: Schema.string().default('skillre/workbranch'),
|
|
15
|
+
remoteUrl: Schema.string().default(''),
|
|
16
|
+
cacheRoot: Schema.string().default(DEFAULT_CACHE_ROOT),
|
|
17
|
+
defaultBranch: Schema.string().default('main'),
|
|
18
|
+
cloneTimeoutMs: Schema.number().min(5_000).max(600_000).step(1).default(120_000),
|
|
19
|
+
fetchTimeoutMs: Schema.number().min(5_000).max(600_000).step(1).default(60_000),
|
|
20
|
+
stallDays: Schema.number().min(1).max(365).step(1).default(45),
|
|
21
|
+
});
|
|
22
|
+
/** `owner/name` on GitHub; the only repository shape the clone command accepts. */
|
|
23
|
+
const REPOSITORY_PATTERN = /^[A-Za-z0-9][A-Za-z0-9-]{0,38}\/[A-Za-z0-9._-]{1,100}$/;
|
|
24
|
+
/** Branch names git accepts, minus the ref-spec metacharacters. */
|
|
25
|
+
const BRANCH_PATTERN = /^[A-Za-z0-9][A-Za-z0-9._/-]{0,200}$/;
|
|
26
|
+
/**
|
|
27
|
+
* Resolve raw row config, keeping the declared defaults authoritative.
|
|
28
|
+
*
|
|
29
|
+
* The shape checks that Schemastery cannot express (a repository is
|
|
30
|
+
* `owner/name`, a branch has no ref-spec metacharacters) run here so a typo
|
|
31
|
+
* fails at mount with a readable message instead of as a git exit code later.
|
|
32
|
+
*/
|
|
33
|
+
export function resolveConfig(raw = {}) {
|
|
34
|
+
const resolved = Config(raw);
|
|
35
|
+
if (!REPOSITORY_PATTERN.test(resolved.repository)) {
|
|
36
|
+
throw new Error(`work dashboard: repository must be "owner/name" on GitHub, received ${JSON.stringify(resolved.repository)}.`);
|
|
37
|
+
}
|
|
38
|
+
if (!BRANCH_PATTERN.test(resolved.defaultBranch) || resolved.defaultBranch.includes('..')) {
|
|
39
|
+
throw new Error(`work dashboard: defaultBranch is not a valid git branch name: ${JSON.stringify(resolved.defaultBranch)}.`);
|
|
40
|
+
}
|
|
41
|
+
if (resolved.cacheRoot.trim() === '')
|
|
42
|
+
throw new Error('work dashboard: cacheRoot must not be empty.');
|
|
43
|
+
const remote = resolved.remoteUrl.trim();
|
|
44
|
+
if (remote !== '' && !/^(?:https:\/\/[^\s]+|git@[^\s:]+:.+|file:\/\/[^\s]+|\/[^\s]+)$/.test(remote)) {
|
|
45
|
+
throw new Error(`work dashboard: remoteUrl is not a supported git URL: ${JSON.stringify(remote)}.`);
|
|
46
|
+
}
|
|
47
|
+
return resolved;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Expand a leading `~` to the current user's home directory.
|
|
51
|
+
*
|
|
52
|
+
* Kept out of {@link resolveConfig} so the resolved config stays a faithful
|
|
53
|
+
* echo of what the profile declared, and every filesystem use expands at the
|
|
54
|
+
* point of use instead.
|
|
55
|
+
*/
|
|
56
|
+
/** The clone URL for the configured source, honoring the `remoteUrl` override. */
|
|
57
|
+
export function remoteUrlFor(config) {
|
|
58
|
+
const override = config.remoteUrl.trim();
|
|
59
|
+
return override === '' ? `https://github.com/${config.repository}.git` : override;
|
|
60
|
+
}
|
|
61
|
+
export function expandHome(path, home) {
|
|
62
|
+
if (path === '~')
|
|
63
|
+
return home;
|
|
64
|
+
if (path.startsWith('~/'))
|
|
65
|
+
return `${home}/${path.slice(2)}`;
|
|
66
|
+
return path;
|
|
67
|
+
}
|
package/lib/gap.d.ts
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The twelve v3 gap rules, as pure functions.
|
|
3
|
+
*
|
|
4
|
+
* The rules are hard-coded here on purpose: they are the product's judgement,
|
|
5
|
+
* not repository data, so they must not drift with a script the data source
|
|
6
|
+
* happens to ship. Every rule is a total function of `(record, options)` —
|
|
7
|
+
* no clock, no filesystem, no locale — so `tests/gap.spec.ts` can pin each one
|
|
8
|
+
* to a fixture.
|
|
9
|
+
*
|
|
10
|
+
* The v3 model is **progress-centred**: a project is judged by its latest
|
|
11
|
+
* progress entry, not by a separately-maintained `result` block. Rules 8–10
|
|
12
|
+
* therefore read `progress[progress.length - 1]`, and rule 7 compares "has any
|
|
13
|
+
* progress" against the G2 readiness flag.
|
|
14
|
+
*/
|
|
15
|
+
import type { GapItem, GapLevel, PocRecord, StageId } from './types.js';
|
|
16
|
+
/** Normalize the free-form `stage` string onto a stage id. */
|
|
17
|
+
export declare function normalizeStage(raw: unknown): {
|
|
18
|
+
stage: StageId | null;
|
|
19
|
+
closed: boolean;
|
|
20
|
+
};
|
|
21
|
+
/** Trim a scalar to a string; absent, null and blank all collapse to `''`. */
|
|
22
|
+
export declare function text(value: unknown): string;
|
|
23
|
+
/** `true` when a value carries no content at all. */
|
|
24
|
+
export declare function blank(value: unknown): boolean;
|
|
25
|
+
/** A numeric value, or `null` when absent or not a finite number. */
|
|
26
|
+
export declare function numberOrNull(value: unknown): number | null;
|
|
27
|
+
/** Options the rule set needs from the caller, so it stays clock-free. */
|
|
28
|
+
export interface ScanOptions {
|
|
29
|
+
/** Injected clock: the rules compare against it, tests pin it. */
|
|
30
|
+
now: Date;
|
|
31
|
+
/** Days in one stage after which rule 12 fires. */
|
|
32
|
+
stallDays: number;
|
|
33
|
+
}
|
|
34
|
+
/** Rule metadata: number, severity and sort weight. */
|
|
35
|
+
export declare const RULE_META: Record<GapItem['rule'], {
|
|
36
|
+
no: number;
|
|
37
|
+
level: GapLevel;
|
|
38
|
+
priority: number;
|
|
39
|
+
}>;
|
|
40
|
+
/** The four dimensions, resolved from the v3 `outcome` block. */
|
|
41
|
+
export declare function readDimensions(poc: PocRecord): {
|
|
42
|
+
achievement: boolean;
|
|
43
|
+
evidence: boolean;
|
|
44
|
+
recognition: boolean;
|
|
45
|
+
nextMilestone: boolean;
|
|
46
|
+
};
|
|
47
|
+
/** The newest progress entry, or `null`. */
|
|
48
|
+
export declare function latestProgress(poc: PocRecord): Record<string, unknown> | null;
|
|
49
|
+
/** The newest progress date, or `null`. */
|
|
50
|
+
export declare function lastProgressDate(poc: PocRecord): string | null;
|
|
51
|
+
/** Whole days between a `YYYY-MM-DD` date and the scan clock. */
|
|
52
|
+
export declare function daysSince(date: string | null, now: Date): number | null;
|
|
53
|
+
/**
|
|
54
|
+
* Scan one record and return every v3 gap it has.
|
|
55
|
+
*
|
|
56
|
+
* The returned list is ordered by severity then rule number; the overview page
|
|
57
|
+
* concatenates the per-project lists and re-sorts, so order here only has to be
|
|
58
|
+
* stable for tests.
|
|
59
|
+
*/
|
|
60
|
+
export declare function scanGaps(poc: PocRecord, options: ScanOptions): GapItem[];
|
package/lib/gap.js
ADDED
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The twelve v3 gap rules, as pure functions.
|
|
3
|
+
*
|
|
4
|
+
* The rules are hard-coded here on purpose: they are the product's judgement,
|
|
5
|
+
* not repository data, so they must not drift with a script the data source
|
|
6
|
+
* happens to ship. Every rule is a total function of `(record, options)` —
|
|
7
|
+
* no clock, no filesystem, no locale — so `tests/gap.spec.ts` can pin each one
|
|
8
|
+
* to a fixture.
|
|
9
|
+
*
|
|
10
|
+
* The v3 model is **progress-centred**: a project is judged by its latest
|
|
11
|
+
* progress entry, not by a separately-maintained `result` block. Rules 8–10
|
|
12
|
+
* therefore read `progress[progress.length - 1]`, and rule 7 compares "has any
|
|
13
|
+
* progress" against the G2 readiness flag.
|
|
14
|
+
*/
|
|
15
|
+
/** Stage prefixes a raw `stage` value can normalize to, in order. */
|
|
16
|
+
const STAGE_PREFIXES = [
|
|
17
|
+
['G0', 'G0'],
|
|
18
|
+
['G1', 'G1'],
|
|
19
|
+
['G2', 'G2'],
|
|
20
|
+
['G3', 'G3'],
|
|
21
|
+
['G4', 'G4'],
|
|
22
|
+
];
|
|
23
|
+
/** Normalize the free-form `stage` string onto a stage id. */
|
|
24
|
+
export function normalizeStage(raw) {
|
|
25
|
+
const value = typeof raw === 'string' ? raw.trim() : '';
|
|
26
|
+
if (value === '')
|
|
27
|
+
return { stage: null, closed: false };
|
|
28
|
+
if (value.toLowerCase() === 'closed')
|
|
29
|
+
return { stage: null, closed: true };
|
|
30
|
+
for (const [stage, prefix] of STAGE_PREFIXES) {
|
|
31
|
+
if (value === prefix || value.startsWith(`${prefix}-`))
|
|
32
|
+
return { stage, closed: false };
|
|
33
|
+
}
|
|
34
|
+
return { stage: null, closed: false };
|
|
35
|
+
}
|
|
36
|
+
/** Trim a scalar to a string; absent, null and blank all collapse to `''`. */
|
|
37
|
+
export function text(value) {
|
|
38
|
+
if (value === null || value === undefined)
|
|
39
|
+
return '';
|
|
40
|
+
if (typeof value === 'string')
|
|
41
|
+
return value.trim();
|
|
42
|
+
if (typeof value === 'number' || typeof value === 'boolean')
|
|
43
|
+
return String(value);
|
|
44
|
+
return '';
|
|
45
|
+
}
|
|
46
|
+
/** `true` when a value carries no content at all. */
|
|
47
|
+
export function blank(value) {
|
|
48
|
+
if (Array.isArray(value))
|
|
49
|
+
return value.length === 0;
|
|
50
|
+
return text(value) === '';
|
|
51
|
+
}
|
|
52
|
+
/** A numeric value, or `null` when absent or not a finite number. */
|
|
53
|
+
export function numberOrNull(value) {
|
|
54
|
+
if (typeof value === 'number' && Number.isFinite(value))
|
|
55
|
+
return value;
|
|
56
|
+
if (typeof value === 'string' && value.trim() !== '') {
|
|
57
|
+
const parsed = Number(value);
|
|
58
|
+
return Number.isFinite(parsed) ? parsed : null;
|
|
59
|
+
}
|
|
60
|
+
return null;
|
|
61
|
+
}
|
|
62
|
+
/** Rule metadata: number, severity and sort weight. */
|
|
63
|
+
export const RULE_META = {
|
|
64
|
+
// R1: the G0 floor. Nothing downstream is trustworthy without it.
|
|
65
|
+
'R1-gate0-missing': { no: 1, level: 'high', priority: 90 },
|
|
66
|
+
// R2: a large commitment decided before the gate was cleared.
|
|
67
|
+
'R2-large-amount-no-g0': { no: 2, level: 'high', priority: 94 },
|
|
68
|
+
// R3: cleared the gate, then never wrote down what success means.
|
|
69
|
+
'R3-g0-passed-no-plan': { no: 3, level: 'high', priority: 92 },
|
|
70
|
+
// R4–R6: focus. A pilot measuring everything measures nothing.
|
|
71
|
+
'R4-criteria-count': { no: 4, level: 'medium', priority: 50 },
|
|
72
|
+
'R5-scenarios-count': { no: 5, level: 'medium', priority: 48 },
|
|
73
|
+
'R6-risks-overflow': { no: 6, level: 'medium', priority: 46 },
|
|
74
|
+
// R7: testing before the prerequisites are ready burns team time.
|
|
75
|
+
'R7-g2-not-ready': { no: 7, level: 'high', priority: 84 },
|
|
76
|
+
// R8–R10: the proof chain, read from the newest progress entry.
|
|
77
|
+
'R8-progress-no-evidence': { no: 8, level: 'high', priority: 82 },
|
|
78
|
+
'R9-evidence-no-recognition': { no: 9, level: 'high', priority: 80 },
|
|
79
|
+
'R10-g3-1-without-g3-2': { no: 10, level: 'high', priority: 78 },
|
|
80
|
+
// R11: it worked, and nothing followed. The highest-value gap, as the
|
|
81
|
+
// original design documented: value was created and none of it was banked.
|
|
82
|
+
'R11-no-next-milestone': { no: 11, level: 'high', priority: 96 },
|
|
83
|
+
// R12: the project has not moved.
|
|
84
|
+
'R12-stage-stalled': { no: 12, level: 'medium', priority: 40 },
|
|
85
|
+
};
|
|
86
|
+
/** Build one finding, stamping the rule metadata from {@link RULE_META}. */
|
|
87
|
+
function gap(poc, rule, extra = {}) {
|
|
88
|
+
const meta = RULE_META[rule];
|
|
89
|
+
return {
|
|
90
|
+
rule,
|
|
91
|
+
ruleNo: meta.no,
|
|
92
|
+
level: meta.level,
|
|
93
|
+
priority: meta.priority,
|
|
94
|
+
pocId: text(poc.poc_id),
|
|
95
|
+
pocName: text(poc.name),
|
|
96
|
+
...extra,
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
/** The four dimensions, resolved from the v3 `outcome` block. */
|
|
100
|
+
export function readDimensions(poc) {
|
|
101
|
+
const outcome = poc.outcome ?? {};
|
|
102
|
+
const progress = Array.isArray(poc.progress) ? poc.progress : [];
|
|
103
|
+
const last = progress.length === 0 ? null : progress[progress.length - 1];
|
|
104
|
+
// `outcome` is mostly auto-derived from the last progress entry, so a project
|
|
105
|
+
// that has progressed but not yet had its outcome summarised still counts:
|
|
106
|
+
// evidence exists when either the outcome or the newest entry carries it.
|
|
107
|
+
const lastEvidence = Array.isArray(last?.evidence) ? last.evidence : [];
|
|
108
|
+
return {
|
|
109
|
+
achievement: !blank(outcome.achievement),
|
|
110
|
+
evidence: !blank(outcome.our_proof) || lastEvidence.length > 0,
|
|
111
|
+
recognition: !blank(outcome.customer_recognition),
|
|
112
|
+
nextMilestone: !blank(outcome.business?.milestone),
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
/** The newest progress entry, or `null`. */
|
|
116
|
+
export function latestProgress(poc) {
|
|
117
|
+
const progress = Array.isArray(poc.progress) ? poc.progress : [];
|
|
118
|
+
const last = progress.length === 0 ? null : progress[progress.length - 1];
|
|
119
|
+
return (last ?? null);
|
|
120
|
+
}
|
|
121
|
+
/** The newest progress date, or `null`. */
|
|
122
|
+
export function lastProgressDate(poc) {
|
|
123
|
+
const progress = Array.isArray(poc.progress) ? poc.progress : [];
|
|
124
|
+
let newest = null;
|
|
125
|
+
for (const entry of progress) {
|
|
126
|
+
const date = text(entry?.date);
|
|
127
|
+
if (!/^\d{4}-\d{2}-\d{2}$/.test(date))
|
|
128
|
+
continue;
|
|
129
|
+
if (Number.isNaN(Date.parse(`${date}T00:00:00Z`)))
|
|
130
|
+
continue;
|
|
131
|
+
if (newest === null || date > newest)
|
|
132
|
+
newest = date;
|
|
133
|
+
}
|
|
134
|
+
return newest;
|
|
135
|
+
}
|
|
136
|
+
/** Whole days between a `YYYY-MM-DD` date and the scan clock. */
|
|
137
|
+
export function daysSince(date, now) {
|
|
138
|
+
if (date === null)
|
|
139
|
+
return null;
|
|
140
|
+
const stamp = Date.parse(`${date}T00:00:00Z`);
|
|
141
|
+
if (Number.isNaN(stamp))
|
|
142
|
+
return null;
|
|
143
|
+
return Math.floor((now.getTime() - stamp) / 86_400_000);
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Scan one record and return every v3 gap it has.
|
|
147
|
+
*
|
|
148
|
+
* The returned list is ordered by severity then rule number; the overview page
|
|
149
|
+
* concatenates the per-project lists and re-sorts, so order here only has to be
|
|
150
|
+
* stable for tests.
|
|
151
|
+
*/
|
|
152
|
+
export function scanGaps(poc, options) {
|
|
153
|
+
const gaps = [];
|
|
154
|
+
const gate0 = poc.gate0 ?? {};
|
|
155
|
+
const plan = poc.plan ?? {};
|
|
156
|
+
const outcome = poc.outcome ?? {};
|
|
157
|
+
const amountWan = numberOrNull(poc.amount_wan) ?? 0;
|
|
158
|
+
const progress = Array.isArray(poc.progress) ? poc.progress : [];
|
|
159
|
+
const last = latestProgress(poc);
|
|
160
|
+
// R1 — the five G0 prerequisites. `gate0.missing` is computed by the ledger and
|
|
161
|
+
// was verified against actual field emptiness, so it is trusted as-is.
|
|
162
|
+
const missing = Array.isArray(gate0.missing) ? gate0.missing.map(text).filter((item) => item !== '') : [];
|
|
163
|
+
if (missing.length > 0) {
|
|
164
|
+
gaps.push(gap(poc, 'R1-gate0-missing', { field: 'gate0.missing', params: { count: missing.length, missing: missing.join(',') } }));
|
|
165
|
+
}
|
|
166
|
+
// R2 — a large commitment whose G0 was never cleared.
|
|
167
|
+
const conclusion = text(gate0.review?.conclusion);
|
|
168
|
+
if (amountWan >= 300 && conclusion !== '通过') {
|
|
169
|
+
gaps.push(gap(poc, 'R2-large-amount-no-g0', { field: 'gate0.review.conclusion', params: { amountWan, conclusion: conclusion === '' ? '未评审' : conclusion } }));
|
|
170
|
+
}
|
|
171
|
+
// R3 — cleared the gate but never defined success.
|
|
172
|
+
if (conclusion === '通过' && (plan.criteria ?? []).length === 0) {
|
|
173
|
+
gaps.push(gap(poc, 'R3-g0-passed-no-plan', { field: 'plan.criteria' }));
|
|
174
|
+
}
|
|
175
|
+
// R4–R6 — focus limits. Only fires when the list is non-empty, so a project
|
|
176
|
+
// that has not planned yet is not punished twice (R3 covers that case).
|
|
177
|
+
const criteria = (plan.criteria ?? []).length;
|
|
178
|
+
if (criteria > 0 && (criteria < 2 || criteria > 3)) {
|
|
179
|
+
gaps.push(gap(poc, 'R4-criteria-count', { field: 'plan.criteria', params: { count: criteria, min: 2, max: 3 } }));
|
|
180
|
+
}
|
|
181
|
+
const scenarios = (plan.scenarios ?? []).length;
|
|
182
|
+
if (scenarios > 0 && (scenarios < 3 || scenarios > 5)) {
|
|
183
|
+
gaps.push(gap(poc, 'R5-scenarios-count', { field: 'plan.scenarios', params: { count: scenarios, min: 3, max: 5 } }));
|
|
184
|
+
}
|
|
185
|
+
const risks = (plan.risks ?? []).length;
|
|
186
|
+
if (risks > 3) {
|
|
187
|
+
gaps.push(gap(poc, 'R6-risks-overflow', { field: 'plan.risks', params: { count: risks, max: 3 } }));
|
|
188
|
+
}
|
|
189
|
+
// R7 — testing started before G2 was ready.
|
|
190
|
+
const ready = text(plan.gate2?.ready);
|
|
191
|
+
if (progress.length > 0 && ready !== 'Ready') {
|
|
192
|
+
gaps.push(gap(poc, 'R7-g2-not-ready', { field: 'plan.gate2.ready', params: { ready: ready === '' ? '未设置' : ready } }));
|
|
193
|
+
}
|
|
194
|
+
// R8–R10 — the proof chain, judged by the NEWEST progress entry only.
|
|
195
|
+
if (last !== null) {
|
|
196
|
+
const evidence = Array.isArray(last.evidence) ? last.evidence : [];
|
|
197
|
+
const actual = text(last.actual);
|
|
198
|
+
const recognition = text(last.customer?.recognition);
|
|
199
|
+
// R8: a claimed result with nothing behind it.
|
|
200
|
+
if (actual !== '' && evidence.length === 0) {
|
|
201
|
+
gaps.push(gap(poc, 'R8-progress-no-evidence', { field: 'progress.evidence', params: { seq: numberOrNull(last.seq) ?? 0 } }));
|
|
202
|
+
}
|
|
203
|
+
// R9: evidence exists, but the customer has not confirmed it.
|
|
204
|
+
if (evidence.length > 0 && (recognition === '未认可' || recognition === '待确认')) {
|
|
205
|
+
gaps.push(gap(poc, 'R9-evidence-no-recognition', { field: 'progress.customer.recognition', params: { recognition } }));
|
|
206
|
+
}
|
|
207
|
+
// R10: provable, but never confirmed.
|
|
208
|
+
if (text(last.gate3_1) === '可证明' && text(last.gate3_2) !== '已确认') {
|
|
209
|
+
gaps.push(gap(poc, 'R10-g3-1-without-g3-2', { field: 'progress.gate3_2', params: { gate3_2: text(last.gate3_2) === '' ? '未填' : text(last.gate3_2) } }));
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
// R11 — achieved, and no next milestone: value created, none banked.
|
|
213
|
+
if (text(outcome.achievement) === '达成' && blank(outcome.business?.milestone)) {
|
|
214
|
+
gaps.push(gap(poc, 'R11-no-next-milestone', { field: 'outcome.business.milestone' }));
|
|
215
|
+
}
|
|
216
|
+
// R12 — the project has not moved for `stallDays`.
|
|
217
|
+
// The schema says `stage_since`; a project without it cannot be judged, so it
|
|
218
|
+
// is not reported rather than assumed stale.
|
|
219
|
+
const since = text(poc.stage_since);
|
|
220
|
+
if (/^\d{4}-\d{2}-\d{2}$/.test(since)) {
|
|
221
|
+
const days = daysSince(since, options.now);
|
|
222
|
+
if (days !== null && days > options.stallDays) {
|
|
223
|
+
gaps.push(gap(poc, 'R12-stage-stalled', { field: 'stage_since', params: { days, stage: text(poc.stage), stallDays: options.stallDays } }));
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
return gaps.sort((left, right) => right.priority - left.priority || left.ruleNo - right.ruleNo || left.rule.localeCompare(right.rule));
|
|
227
|
+
}
|
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Host entry of the work dashboard.
|
|
3
|
+
*
|
|
4
|
+
* Ownership split: this half owns the disposable git cache, the YAML parse and
|
|
5
|
+
* the gap scan, and exposes them through one Connection route; the Client half
|
|
6
|
+
* owns only view state (which page, which project, the refresh cadence).
|
|
7
|
+
*
|
|
8
|
+
* Everything registered here belongs to this plugin's Fiber, so stopping or
|
|
9
|
+
* updating the row releases the route and the cache lifetime with no residue.
|
|
10
|
+
*
|
|
11
|
+
* The cache is wiped at mount, per the specification: the repository on GitHub
|
|
12
|
+
* is the only truth, and a stale local copy must never be mistaken for it.
|
|
13
|
+
*/
|
|
14
|
+
import type { Context } from '@deepseek-ai/cordis';
|
|
15
|
+
import { resolveConfig } from './config.js';
|
|
16
|
+
import type { WorkDashboardConfig } from './config.js';
|
|
17
|
+
import { RepoError } from './repo.js';
|
|
18
|
+
import type { ConsoleActions } from './transport.js';
|
|
19
|
+
export { resolveConfig };
|
|
20
|
+
export { Config } from './config.js';
|
|
21
|
+
export declare const name = "skillre-work-dashboard";
|
|
22
|
+
/**
|
|
23
|
+
* Required services. `connection` provides the authenticated Client route; it
|
|
24
|
+
* is a hard dependency so a profile without it fails loudly instead of mounting
|
|
25
|
+
* a board that can never be reached.
|
|
26
|
+
*/
|
|
27
|
+
export declare const inject: string[];
|
|
28
|
+
/** The console facade the route dispatches onto. */
|
|
29
|
+
export interface DashboardRuntime extends ConsoleActions {
|
|
30
|
+
/** Wipe the cache (mount) and resolve the store. */
|
|
31
|
+
prepare(): Promise<void>;
|
|
32
|
+
}
|
|
33
|
+
/** Build the runtime around one resolved configuration. */
|
|
34
|
+
export declare function createRuntime(config: WorkDashboardConfig, options?: {
|
|
35
|
+
home?: string;
|
|
36
|
+
now?: () => Date;
|
|
37
|
+
}): DashboardRuntime;
|
|
38
|
+
export declare function apply(ctx: Context, rawConfig?: Partial<WorkDashboardConfig>): void;
|
|
39
|
+
/** Re-export the error type so tests and the transport share one identity. */
|
|
40
|
+
export { RepoError };
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Host entry of the work dashboard.
|
|
3
|
+
*
|
|
4
|
+
* Ownership split: this half owns the disposable git cache, the YAML parse and
|
|
5
|
+
* the gap scan, and exposes them through one Connection route; the Client half
|
|
6
|
+
* owns only view state (which page, which project, the refresh cadence).
|
|
7
|
+
*
|
|
8
|
+
* Everything registered here belongs to this plugin's Fiber, so stopping or
|
|
9
|
+
* updating the row releases the route and the cache lifetime with no residue.
|
|
10
|
+
*
|
|
11
|
+
* The cache is wiped at mount, per the specification: the repository on GitHub
|
|
12
|
+
* is the only truth, and a stale local copy must never be mistaken for it.
|
|
13
|
+
*/
|
|
14
|
+
import { homedir } from 'node:os';
|
|
15
|
+
import YAML from 'yaml';
|
|
16
|
+
import { resolveConfig, expandHome, remoteUrlFor } from './config.js';
|
|
17
|
+
import { PocStore } from './store.js';
|
|
18
|
+
import { RepoCache, RepoError, assertSafeCacheRoot } from './repo.js';
|
|
19
|
+
import { buildRiskBoard } from './risks.js';
|
|
20
|
+
import { buildGlobalTimeline } from './timeline.js';
|
|
21
|
+
import { registerBundledSkills } from './skill.js';
|
|
22
|
+
import { createExecuteRoute } from './transport.js';
|
|
23
|
+
export { resolveConfig };
|
|
24
|
+
export { Config } from './config.js';
|
|
25
|
+
export const name = 'skillre-work-dashboard';
|
|
26
|
+
/**
|
|
27
|
+
* Required services. `connection` provides the authenticated Client route; it
|
|
28
|
+
* is a hard dependency so a profile without it fails loudly instead of mounting
|
|
29
|
+
* a board that can never be reached.
|
|
30
|
+
*/
|
|
31
|
+
export const inject = ['connection'];
|
|
32
|
+
/** Read an optional Cordis service without declaring it required. */
|
|
33
|
+
function service(ctx, key) {
|
|
34
|
+
return ctx.get(key);
|
|
35
|
+
}
|
|
36
|
+
/** Build the runtime around one resolved configuration. */
|
|
37
|
+
export function createRuntime(config, options = {}) {
|
|
38
|
+
const home = options.home ?? homedir();
|
|
39
|
+
const cacheRoot = assertSafeCacheRoot(expandHome(config.cacheRoot, home), home);
|
|
40
|
+
const now = options.now ?? (() => new Date());
|
|
41
|
+
const remoteUrl = remoteUrlFor(config);
|
|
42
|
+
const cache = new RepoCache({
|
|
43
|
+
cacheRoot,
|
|
44
|
+
repository: config.repository,
|
|
45
|
+
branch: config.defaultBranch,
|
|
46
|
+
remoteUrl,
|
|
47
|
+
cloneTimeoutMs: config.cloneTimeoutMs,
|
|
48
|
+
fetchTimeoutMs: config.fetchTimeoutMs,
|
|
49
|
+
});
|
|
50
|
+
const store = new PocStore(cache, { now, stallDays: config.stallDays });
|
|
51
|
+
let prepared = null;
|
|
52
|
+
/**
|
|
53
|
+
* Load the records, treating a cold cache as an EMPTY ledger.
|
|
54
|
+
*
|
|
55
|
+
* The board, the risk board and the timeline are all reachable before the
|
|
56
|
+
* first Refresh; "no data yet" is the honest answer there, so a missing clone
|
|
57
|
+
* (or a repository without `projects/`) yields no records rather than an error.
|
|
58
|
+
*/
|
|
59
|
+
const loadOrEmpty = async () => {
|
|
60
|
+
try {
|
|
61
|
+
return (await store.load()).records;
|
|
62
|
+
}
|
|
63
|
+
catch (error) {
|
|
64
|
+
if (error instanceof RepoError && (error.code === 'no-projects' || error.code === 'not-found'))
|
|
65
|
+
return [];
|
|
66
|
+
throw error;
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
return {
|
|
70
|
+
async prepare() {
|
|
71
|
+
prepared ??= cache.prepare();
|
|
72
|
+
return prepared;
|
|
73
|
+
},
|
|
74
|
+
async snapshot() {
|
|
75
|
+
await this.prepare();
|
|
76
|
+
return store.snapshot();
|
|
77
|
+
},
|
|
78
|
+
async refresh() {
|
|
79
|
+
await this.prepare();
|
|
80
|
+
const outcome = await cache.refresh();
|
|
81
|
+
return { snapshot: await store.snapshot(), outcome };
|
|
82
|
+
},
|
|
83
|
+
async detail(pocId) {
|
|
84
|
+
await this.prepare();
|
|
85
|
+
return store.detail(pocId);
|
|
86
|
+
},
|
|
87
|
+
async risks() {
|
|
88
|
+
await this.prepare();
|
|
89
|
+
return buildRiskBoard(await loadOrEmpty(), { now: now(), stallDays: config.stallDays });
|
|
90
|
+
},
|
|
91
|
+
async timeline() {
|
|
92
|
+
await this.prepare();
|
|
93
|
+
return buildGlobalTimeline(await loadOrEmpty(), { stallDays: config.stallDays });
|
|
94
|
+
},
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
export function apply(ctx, rawConfig = {}) {
|
|
98
|
+
const config = resolveConfig(rawConfig);
|
|
99
|
+
const connection = service(ctx, 'connection');
|
|
100
|
+
if (!connection?.fetch?.register)
|
|
101
|
+
throw new Error('work dashboard requires the current DSH Connection exact Fetch-route registry.');
|
|
102
|
+
const runtime = createRuntime(config);
|
|
103
|
+
// The three POC skills ship inside this package, so installing the dashboard
|
|
104
|
+
// is what publishes them and uninstalling is what removes them. Registration
|
|
105
|
+
// is optional-service and best-effort: a profile without a skill registry
|
|
106
|
+
// still gets the board (see src/skill.ts).
|
|
107
|
+
registerBundledSkills(ctx);
|
|
108
|
+
// The wipe runs once, on mount. It is not awaited here — a filesystem failure
|
|
109
|
+
// must not abort the Fiber — but it is logged once and then surfaces on the
|
|
110
|
+
// first request through the shared `prepared` promise.
|
|
111
|
+
runtime.prepare().catch((error) => {
|
|
112
|
+
ctx.logger?.error?.(`work-dashboard: cache preparation failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
113
|
+
});
|
|
114
|
+
ctx.effect(() => () => {
|
|
115
|
+
// The cache is a plain directory that the next mount wipes anyway; the
|
|
116
|
+
// effect exists so the Fiber owns the runtime's lifetime explicitly.
|
|
117
|
+
void runtime;
|
|
118
|
+
}, 'skillre-work-dashboard cache lifetime');
|
|
119
|
+
ctx.effect(() => connection.fetch.register(createExecuteRoute(async () => runtime, {
|
|
120
|
+
onInternalError(error) {
|
|
121
|
+
const detail = error instanceof Error ? `${error.name}: ${error.message}\n${error.stack ?? ''}` : String(error);
|
|
122
|
+
ctx.logger?.error?.(`work-dashboard: request failed internally: ${detail}`);
|
|
123
|
+
// Also surface it on the Host stderr: a DSH deployment may not route
|
|
124
|
+
// `ctx.logger` to a place the operator looks at.
|
|
125
|
+
process.stderr.write(`[work-dashboard] internal error: ${detail}\n`);
|
|
126
|
+
},
|
|
127
|
+
})), 'skillre-work-dashboard client route');
|
|
128
|
+
}
|
|
129
|
+
/** Re-export the error type so tests and the transport share one identity. */
|
|
130
|
+
export { RepoError };
|