@rine-kit/presentation 0.0.0-stage → 0.1.1
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/dist/src/builders/pubg.d.ts +35 -0
- package/dist/src/builders/pubg.js +725 -0
- package/dist/src/contracts/owner.d.ts +20 -0
- package/dist/src/contracts/owner.js +1 -0
- package/dist/src/contracts/pubg.d.ts +200 -0
- package/dist/src/contracts/pubg.js +1 -0
- package/dist/src/contracts/session-review.d.ts +72 -0
- package/dist/src/contracts/session-review.js +1 -0
- package/dist/src/index.d.ts +19 -0
- package/dist/src/index.js +19 -0
- package/dist/src/pubg-registry.d.ts +21 -0
- package/dist/src/pubg-registry.js +123 -0
- package/dist/src/renderers/daily-review.d.ts +22 -0
- package/dist/src/renderers/daily-review.js +149 -0
- package/dist/src/renderers/owner.d.ts +6 -0
- package/dist/src/renderers/owner.js +35 -0
- package/dist/src/renderers/pubg.d.ts +22 -0
- package/dist/src/renderers/pubg.js +603 -0
- package/dist/src/renderers/session-review.d.ts +15 -0
- package/dist/src/renderers/session-review.js +187 -0
- package/dist/src/reply-check.d.ts +3 -0
- package/dist/src/reply-check.js +44 -0
- package/dist/src/reply-guides.d.ts +10 -0
- package/dist/src/reply-guides.js +64 -0
- package/dist/src/time/format.d.ts +16 -0
- package/dist/src/time/format.js +63 -0
- package/dist/src/validation/session-review.d.ts +3 -0
- package/dist/src/validation/session-review.js +136 -0
- package/dist/src/validation/validate.d.ts +18 -0
- package/dist/src/validation/validate.js +736 -0
- package/dist/src/worldline/adapter.d.ts +3 -0
- package/dist/src/worldline/adapter.js +47 -0
- package/dist/src/worldline/contracts.d.ts +44 -0
- package/dist/src/worldline/contracts.js +40 -0
- package/dist/src/worldline/policy.d.ts +2 -0
- package/dist/src/worldline/policy.js +31 -0
- package/dist/src/worldline/renderer.d.ts +3 -0
- package/dist/src/worldline/renderer.js +5 -0
- package/dist/src/worldline/vocabulary.d.ts +2 -0
- package/dist/src/worldline/vocabulary.js +1 -0
- package/package.json +33 -3
- package/README.md +0 -3
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { PresentationFact, PresentationLink, WorldlineSignificance, WorldlineTheme } from '../worldline/contracts.js';
|
|
2
|
+
export type OwnerNotificationSeverity = 'info' | 'success' | 'warning' | 'error';
|
|
3
|
+
export type OwnerNotificationFact = PresentationFact;
|
|
4
|
+
export type OwnerNotificationLink = PresentationLink;
|
|
5
|
+
export interface OwnerNotificationPresentation {
|
|
6
|
+
type: 'owner_notification';
|
|
7
|
+
eventType: string;
|
|
8
|
+
severity: OwnerNotificationSeverity;
|
|
9
|
+
significance: WorldlineSignificance;
|
|
10
|
+
theme: WorldlineTheme;
|
|
11
|
+
eventKey: string;
|
|
12
|
+
source: string;
|
|
13
|
+
headline: string;
|
|
14
|
+
facts: OwnerNotificationFact[];
|
|
15
|
+
links?: OwnerNotificationLink[];
|
|
16
|
+
summary?: string;
|
|
17
|
+
dataUpdatedAt?: string;
|
|
18
|
+
occurredAt: string;
|
|
19
|
+
worldLineClosing?: boolean;
|
|
20
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
export type PubgPresentationStatus = 'ok' | 'partial' | 'no_matches' | 'error';
|
|
2
|
+
export interface PubgSourceRangeSegment {
|
|
3
|
+
label: string;
|
|
4
|
+
from: string | null;
|
|
5
|
+
to: string | null;
|
|
6
|
+
}
|
|
7
|
+
export interface PubgSourceRange {
|
|
8
|
+
from: string | null;
|
|
9
|
+
to: string | null;
|
|
10
|
+
segments?: PubgSourceRangeSegment[];
|
|
11
|
+
}
|
|
12
|
+
export interface PubgPresentationBase {
|
|
13
|
+
status: PubgPresentationStatus;
|
|
14
|
+
dataUpdatedAt: string;
|
|
15
|
+
sourceRange?: PubgSourceRange;
|
|
16
|
+
coverage?: PubgPresentationCoverage;
|
|
17
|
+
}
|
|
18
|
+
/** Provenance facts passed through from the shared Domain envelope. */
|
|
19
|
+
export interface PubgPresentationCoverage {
|
|
20
|
+
status: string;
|
|
21
|
+
complete: boolean;
|
|
22
|
+
freshness: 'fresh' | 'stale' | 'unknown';
|
|
23
|
+
checkedAt: string | null;
|
|
24
|
+
coverageStart: string | null;
|
|
25
|
+
coverageEnd: string | null;
|
|
26
|
+
sourceUnavailable: boolean;
|
|
27
|
+
}
|
|
28
|
+
export interface PresentationTextItem {
|
|
29
|
+
text: string;
|
|
30
|
+
evidenceRefs: string[];
|
|
31
|
+
}
|
|
32
|
+
export type PubgPresentationScalar = string | number | null;
|
|
33
|
+
export interface PubgMetricRow {
|
|
34
|
+
label: string;
|
|
35
|
+
values: Record<string, PubgPresentationScalar>;
|
|
36
|
+
position?: number | null;
|
|
37
|
+
evidenceRefs: string[];
|
|
38
|
+
}
|
|
39
|
+
export interface PubgMatchReviewOverview {
|
|
40
|
+
placement: number | null;
|
|
41
|
+
kills: number | null;
|
|
42
|
+
assists: number | null;
|
|
43
|
+
damage: number | null;
|
|
44
|
+
dbnos: number | null;
|
|
45
|
+
revives: number | null;
|
|
46
|
+
}
|
|
47
|
+
export interface PubgMatchReviewPresentation extends PubgPresentationBase {
|
|
48
|
+
type: 'pubg_match_review';
|
|
49
|
+
headline: string;
|
|
50
|
+
overview: PubgMatchReviewOverview;
|
|
51
|
+
keyMoments: PresentationTextItem[];
|
|
52
|
+
highlights: PresentationTextItem[];
|
|
53
|
+
improvements: PresentationTextItem[];
|
|
54
|
+
analysis: string;
|
|
55
|
+
evidenceRefs: string[];
|
|
56
|
+
}
|
|
57
|
+
export interface PubgPeriodReviewMatch {
|
|
58
|
+
matchId: string;
|
|
59
|
+
label: string;
|
|
60
|
+
startedAt: string | null;
|
|
61
|
+
placement: number | null;
|
|
62
|
+
}
|
|
63
|
+
export interface PubgPeriodReviewPresentation extends PubgPresentationBase {
|
|
64
|
+
type: 'pubg_period_review';
|
|
65
|
+
period: {
|
|
66
|
+
label: string;
|
|
67
|
+
displayDate?: string;
|
|
68
|
+
};
|
|
69
|
+
summary: string;
|
|
70
|
+
orderedMatches: PubgPeriodReviewMatch[];
|
|
71
|
+
highlights: PresentationTextItem[];
|
|
72
|
+
patterns: PresentationTextItem[];
|
|
73
|
+
analysis: string;
|
|
74
|
+
evidenceRefs: string[];
|
|
75
|
+
}
|
|
76
|
+
export interface PubgStatsPresentation extends PubgPresentationBase {
|
|
77
|
+
type: 'pubg_stats';
|
|
78
|
+
headline: string;
|
|
79
|
+
operation: string;
|
|
80
|
+
groupBy: string;
|
|
81
|
+
summary: string;
|
|
82
|
+
rows: PubgMetricRow[];
|
|
83
|
+
evidenceRefs: string[];
|
|
84
|
+
}
|
|
85
|
+
export interface PubgMatchListItem {
|
|
86
|
+
matchId: string;
|
|
87
|
+
startedAt: string | null;
|
|
88
|
+
mapName: string;
|
|
89
|
+
gameMode: string;
|
|
90
|
+
placement: number | null;
|
|
91
|
+
summary: string;
|
|
92
|
+
evidenceRefs: string[];
|
|
93
|
+
}
|
|
94
|
+
export interface PubgMatchListPresentation extends PubgPresentationBase {
|
|
95
|
+
type: 'pubg_match_list';
|
|
96
|
+
headline: string;
|
|
97
|
+
summary: string;
|
|
98
|
+
matches: PubgMatchListItem[];
|
|
99
|
+
evidenceRefs: string[];
|
|
100
|
+
}
|
|
101
|
+
export interface PubgComparisonSegment {
|
|
102
|
+
label: string;
|
|
103
|
+
sourceRange?: PubgSourceRange;
|
|
104
|
+
rows: PubgMetricRow[];
|
|
105
|
+
}
|
|
106
|
+
export interface PubgComparisonPresentation extends PubgPresentationBase {
|
|
107
|
+
type: 'pubg_comparison';
|
|
108
|
+
headline: string;
|
|
109
|
+
summary: string;
|
|
110
|
+
rows: PubgMetricRow[];
|
|
111
|
+
segments: PubgComparisonSegment[];
|
|
112
|
+
evidenceRefs: string[];
|
|
113
|
+
}
|
|
114
|
+
export interface PubgMatchDetailPlayer {
|
|
115
|
+
label: string;
|
|
116
|
+
values: Record<string, PubgPresentationScalar>;
|
|
117
|
+
evidenceRefs: string[];
|
|
118
|
+
}
|
|
119
|
+
export interface PubgMatchDetailPresentation extends PubgPresentationBase {
|
|
120
|
+
type: 'pubg_match_detail';
|
|
121
|
+
headline: string;
|
|
122
|
+
matchId: string;
|
|
123
|
+
startedAt: string | null;
|
|
124
|
+
mapName: string;
|
|
125
|
+
gameMode: string;
|
|
126
|
+
duration: number | null;
|
|
127
|
+
players: PubgMatchDetailPlayer[];
|
|
128
|
+
evidenceRefs: string[];
|
|
129
|
+
}
|
|
130
|
+
export interface PubgTeamDamageDirection {
|
|
131
|
+
actor: string;
|
|
132
|
+
victim: string;
|
|
133
|
+
hitCount: number | null;
|
|
134
|
+
damage: number | null;
|
|
135
|
+
knownHitCount?: number;
|
|
136
|
+
knownDamage?: number;
|
|
137
|
+
complete: boolean;
|
|
138
|
+
evidenceRefs: string[];
|
|
139
|
+
}
|
|
140
|
+
export interface PubgTeamDamageActorTotal {
|
|
141
|
+
actor: string;
|
|
142
|
+
damage: number | null;
|
|
143
|
+
hitCount: number | null;
|
|
144
|
+
knownDamage: number;
|
|
145
|
+
knownHitCount: number;
|
|
146
|
+
complete: boolean;
|
|
147
|
+
position: number;
|
|
148
|
+
evidenceRefs: string[];
|
|
149
|
+
}
|
|
150
|
+
/** One kind of team hit (飞踢, 重拳, a vehicle ram, a gun) with its count and damage. */
|
|
151
|
+
export interface PubgTeamDamageSlice {
|
|
152
|
+
label: string;
|
|
153
|
+
hitCount: number;
|
|
154
|
+
damage: number;
|
|
155
|
+
}
|
|
156
|
+
export interface PubgTeamDamagePair {
|
|
157
|
+
actor: string;
|
|
158
|
+
victim: string;
|
|
159
|
+
hitCount: number;
|
|
160
|
+
damage: number;
|
|
161
|
+
}
|
|
162
|
+
/** The match with the most team damage in the period, for the 名场面 lines. */
|
|
163
|
+
export interface PubgTeamDamageHighlight {
|
|
164
|
+
label: string;
|
|
165
|
+
hitCount: number;
|
|
166
|
+
damage: number;
|
|
167
|
+
pairs: PubgTeamDamagePair[];
|
|
168
|
+
}
|
|
169
|
+
/** Detail behind the totals, read from the per-match telemetry events; absent when no events were returned. */
|
|
170
|
+
export interface PubgTeamDamageLedger {
|
|
171
|
+
sources: PubgTeamDamageSlice[];
|
|
172
|
+
/** Aligned with `directions`: how each direction's hits break down by kind. */
|
|
173
|
+
directionSources: PubgTeamDamageSlice[][];
|
|
174
|
+
highlights: PubgTeamDamageHighlight[];
|
|
175
|
+
/** Players hit by teammates who never hit a teammate themselves. */
|
|
176
|
+
quiet: string[];
|
|
177
|
+
}
|
|
178
|
+
export interface PubgTeamDamagePresentation extends PubgPresentationBase {
|
|
179
|
+
type: 'pubg_team_damage';
|
|
180
|
+
ledger?: PubgTeamDamageLedger;
|
|
181
|
+
headline: string;
|
|
182
|
+
direction: string;
|
|
183
|
+
source: string | null;
|
|
184
|
+
meleeKind: string | null;
|
|
185
|
+
totalHitCount: number | null;
|
|
186
|
+
totalDamage: number | null;
|
|
187
|
+
directions: PubgTeamDamageDirection[];
|
|
188
|
+
actorTotals?: PubgTeamDamageActorTotal[];
|
|
189
|
+
rankingBasis?: 'damage' | 'knownDamage';
|
|
190
|
+
summary: string;
|
|
191
|
+
evidenceRefs: string[];
|
|
192
|
+
}
|
|
193
|
+
export interface PubgStatusPresentation extends PubgPresentationBase {
|
|
194
|
+
type: 'pubg_status';
|
|
195
|
+
headline: string;
|
|
196
|
+
message: string;
|
|
197
|
+
errorCode?: string;
|
|
198
|
+
evidenceRefs: string[];
|
|
199
|
+
}
|
|
200
|
+
export type PubgPresentation = PubgStatsPresentation | PubgMatchListPresentation | PubgComparisonPresentation | PubgMatchDetailPresentation | PubgMatchReviewPresentation | PubgPeriodReviewPresentation | PubgTeamDamagePresentation | PubgStatusPresentation;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* One squad play session (consecutive ranked matches with gaps under the session gap), reviewed for a group chat.
|
|
3
|
+
* Every number is computed deterministically by the PUBG Domain; the renderer only formats and trims.
|
|
4
|
+
*/
|
|
5
|
+
export type SessionFindingTone = 'good' | 'bad' | 'neutral';
|
|
6
|
+
/** `clear` means the interval against the squad's own baseline excludes zero; `observation` is labelled as such. */
|
|
7
|
+
export type SessionFindingConfidence = 'clear' | 'observation';
|
|
8
|
+
export type SessionMemberTag = 'top_damage' | 'early_outs' | 'medic';
|
|
9
|
+
export interface SessionReviewFinding {
|
|
10
|
+
metric: string;
|
|
11
|
+
tone: SessionFindingTone;
|
|
12
|
+
confidence: SessionFindingConfidence;
|
|
13
|
+
text: string;
|
|
14
|
+
}
|
|
15
|
+
export interface SessionReviewMember {
|
|
16
|
+
name: string;
|
|
17
|
+
matches: number;
|
|
18
|
+
kills: number;
|
|
19
|
+
knocks: number;
|
|
20
|
+
damagePerMatch: number;
|
|
21
|
+
earlyOuts: number;
|
|
22
|
+
revives: number;
|
|
23
|
+
tags: SessionMemberTag[];
|
|
24
|
+
}
|
|
25
|
+
export interface SessionReviewMatchNote {
|
|
26
|
+
matchId: string;
|
|
27
|
+
rank: number | null;
|
|
28
|
+
mapName: string;
|
|
29
|
+
text: string;
|
|
30
|
+
}
|
|
31
|
+
export interface SessionReviewTimelineItem {
|
|
32
|
+
atSeconds: number;
|
|
33
|
+
text: string;
|
|
34
|
+
}
|
|
35
|
+
export interface SessionReviewPresentation {
|
|
36
|
+
type: 'pubg_session_review';
|
|
37
|
+
version: 1;
|
|
38
|
+
sessionKey: string;
|
|
39
|
+
squadLabel: string;
|
|
40
|
+
timezone: string;
|
|
41
|
+
startAt: string;
|
|
42
|
+
endAt: string;
|
|
43
|
+
matchCount: number;
|
|
44
|
+
maps: Array<{
|
|
45
|
+
mapName: string;
|
|
46
|
+
count: number;
|
|
47
|
+
}>;
|
|
48
|
+
headline: string;
|
|
49
|
+
/** Team placement per match in play order; null when PUBG did not report one. */
|
|
50
|
+
placements: Array<number | null>;
|
|
51
|
+
summary: {
|
|
52
|
+
avgPlacement: number | null;
|
|
53
|
+
baselineAvgPlacement: number | null;
|
|
54
|
+
wins: number;
|
|
55
|
+
top10: number;
|
|
56
|
+
teamKnocks: number;
|
|
57
|
+
avgTeamDamage: number;
|
|
58
|
+
};
|
|
59
|
+
findings: SessionReviewFinding[];
|
|
60
|
+
members: SessionReviewMember[];
|
|
61
|
+
bestMatch?: SessionReviewMatchNote;
|
|
62
|
+
worstMatch?: SessionReviewMatchNote;
|
|
63
|
+
/** Only for a one-match session: up to three moments of that match. */
|
|
64
|
+
timeline?: SessionReviewTimelineItem[];
|
|
65
|
+
suggestion?: string;
|
|
66
|
+
coverage: {
|
|
67
|
+
telemetry: number;
|
|
68
|
+
total: number;
|
|
69
|
+
};
|
|
70
|
+
link?: string;
|
|
71
|
+
generatedAt: string;
|
|
72
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export * from './contracts/owner.js';
|
|
2
|
+
export * from './contracts/pubg.js';
|
|
3
|
+
export * from './contracts/session-review.js';
|
|
4
|
+
export * from './builders/pubg.js';
|
|
5
|
+
export * from './pubg-registry.js';
|
|
6
|
+
export * from './renderers/owner.js';
|
|
7
|
+
export * from './renderers/pubg.js';
|
|
8
|
+
export * from './renderers/session-review.js';
|
|
9
|
+
export * from './renderers/daily-review.js';
|
|
10
|
+
export * from './time/format.js';
|
|
11
|
+
export * from './validation/validate.js';
|
|
12
|
+
export * from './validation/session-review.js';
|
|
13
|
+
export * from './worldline/contracts.js';
|
|
14
|
+
export * from './worldline/policy.js';
|
|
15
|
+
export * from './worldline/adapter.js';
|
|
16
|
+
export * from './worldline/renderer.js';
|
|
17
|
+
export * from './worldline/vocabulary.js';
|
|
18
|
+
export * from './reply-guides.js';
|
|
19
|
+
export * from './reply-check.js';
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export * from './contracts/owner.js';
|
|
2
|
+
export * from './contracts/pubg.js';
|
|
3
|
+
export * from './contracts/session-review.js';
|
|
4
|
+
export * from './builders/pubg.js';
|
|
5
|
+
export * from './pubg-registry.js';
|
|
6
|
+
export * from './renderers/owner.js';
|
|
7
|
+
export * from './renderers/pubg.js';
|
|
8
|
+
export * from './renderers/session-review.js';
|
|
9
|
+
export * from './renderers/daily-review.js';
|
|
10
|
+
export * from './time/format.js';
|
|
11
|
+
export * from './validation/validate.js';
|
|
12
|
+
export * from './validation/session-review.js';
|
|
13
|
+
export * from './worldline/contracts.js';
|
|
14
|
+
export * from './worldline/policy.js';
|
|
15
|
+
export * from './worldline/adapter.js';
|
|
16
|
+
export * from './worldline/renderer.js';
|
|
17
|
+
export * from './worldline/vocabulary.js';
|
|
18
|
+
export * from './reply-guides.js';
|
|
19
|
+
export * from './reply-check.js';
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { PubgPresentation } from './contracts/pubg.js';
|
|
2
|
+
import type { PubgRenderOptions } from './renderers/pubg.js';
|
|
3
|
+
import { type PubgToolPresentationInput } from './builders/pubg.js';
|
|
4
|
+
export type PubgToolClassification = 'user-facing' | 'intermediate' | 'scheduled';
|
|
5
|
+
export type PubgToolName = 'pubg_resolve_players' | 'pubg_search_matches' | 'pubg_query_stats' | 'pubg_compare_stats' | 'pubg_get_match' | 'pubg_get_review_facts' | 'pubg_get_period_review' | 'pubg_query_team_damage' | 'pubg_prefetch_telemetry' | 'pubg_telemetry_sync_report';
|
|
6
|
+
export interface PubgPresentationRegistration {
|
|
7
|
+
classification: PubgToolClassification;
|
|
8
|
+
build: (input: PubgToolPresentationInput) => PubgPresentation;
|
|
9
|
+
render: (presentation: PubgPresentation, options?: PubgRenderOptions) => string;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* This is the single coverage registry for native PUBG tools. The plugin and
|
|
13
|
+
* architecture check both consume the same named mapping rather than keeping
|
|
14
|
+
* scattered per-tool presentation conditionals.
|
|
15
|
+
*/
|
|
16
|
+
export declare const PUBG_PRESENTATION_REGISTRY: Record<PubgToolName, PubgPresentationRegistration>;
|
|
17
|
+
export declare const PUBG_USER_FACING_TOOLS: PubgToolName[];
|
|
18
|
+
export declare function buildPubgToolPresentation(toolName: string, input: Omit<PubgToolPresentationInput, 'toolName'>, options?: PubgRenderOptions): {
|
|
19
|
+
presentation: PubgPresentation;
|
|
20
|
+
displayText: string;
|
|
21
|
+
};
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { buildPubgComparisonPresentation, buildPubgMatchDetailPresentation, buildPubgPresentation, buildPubgStatsPresentation, buildPubgStatusPresentation, buildPubgTeamDamagePresentation, } from './builders/pubg.js';
|
|
2
|
+
import { renderPubgComparison, renderPubgMatchDetail, renderPubgMatchList, renderPubgMatchReview, renderPubgPeriodReview, renderPubgStats, renderPubgStatus, renderPubgTeamDamage, } from './renderers/pubg.js';
|
|
3
|
+
function renderStats(presentation, options) {
|
|
4
|
+
return presentation.type === 'pubg_stats'
|
|
5
|
+
? renderPubgStats(presentation, options)
|
|
6
|
+
: renderStatus(presentation, options);
|
|
7
|
+
}
|
|
8
|
+
function renderMatchList(presentation, options) {
|
|
9
|
+
return presentation.type === 'pubg_match_list'
|
|
10
|
+
? renderPubgMatchList(presentation, options)
|
|
11
|
+
: renderStatus(presentation, options);
|
|
12
|
+
}
|
|
13
|
+
function renderComparison(presentation, options) {
|
|
14
|
+
return presentation.type === 'pubg_comparison'
|
|
15
|
+
? renderPubgComparison(presentation, options)
|
|
16
|
+
: renderStatus(presentation, options);
|
|
17
|
+
}
|
|
18
|
+
function renderMatchDetail(presentation, options) {
|
|
19
|
+
return presentation.type === 'pubg_match_detail'
|
|
20
|
+
? renderPubgMatchDetail(presentation, options)
|
|
21
|
+
: renderStatus(presentation, options);
|
|
22
|
+
}
|
|
23
|
+
function renderReview(presentation, options) {
|
|
24
|
+
return presentation.type === 'pubg_match_review'
|
|
25
|
+
? renderPubgMatchReview(presentation, options)
|
|
26
|
+
: renderStatus(presentation, options);
|
|
27
|
+
}
|
|
28
|
+
function renderPeriodReview(presentation, options) {
|
|
29
|
+
return presentation.type === 'pubg_period_review'
|
|
30
|
+
? renderPubgPeriodReview(presentation, options)
|
|
31
|
+
: renderStatus(presentation, options);
|
|
32
|
+
}
|
|
33
|
+
function renderTeamDamage(presentation, options) {
|
|
34
|
+
return presentation.type === 'pubg_team_damage'
|
|
35
|
+
? renderPubgTeamDamage(presentation, options)
|
|
36
|
+
: renderStatus(presentation, options);
|
|
37
|
+
}
|
|
38
|
+
function renderStatus(presentation, options) {
|
|
39
|
+
return renderPubgStatus(presentation.type === 'pubg_status'
|
|
40
|
+
? presentation
|
|
41
|
+
: buildPubgStatusPresentation({
|
|
42
|
+
data: {},
|
|
43
|
+
dataUpdatedAt: presentation.dataUpdatedAt,
|
|
44
|
+
status: presentation.status,
|
|
45
|
+
}), options);
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* This is the single coverage registry for native PUBG tools. The plugin and
|
|
49
|
+
* architecture check both consume the same named mapping rather than keeping
|
|
50
|
+
* scattered per-tool presentation conditionals.
|
|
51
|
+
*/
|
|
52
|
+
export const PUBG_PRESENTATION_REGISTRY = {
|
|
53
|
+
pubg_resolve_players: {
|
|
54
|
+
classification: 'intermediate',
|
|
55
|
+
build: buildPubgStatusPresentation,
|
|
56
|
+
render: renderStatus,
|
|
57
|
+
},
|
|
58
|
+
pubg_search_matches: {
|
|
59
|
+
classification: 'user-facing',
|
|
60
|
+
build: buildPubgPresentation,
|
|
61
|
+
render: renderMatchList,
|
|
62
|
+
},
|
|
63
|
+
pubg_query_stats: {
|
|
64
|
+
classification: 'user-facing',
|
|
65
|
+
build: buildPubgStatsPresentation,
|
|
66
|
+
render: renderStats,
|
|
67
|
+
},
|
|
68
|
+
pubg_compare_stats: {
|
|
69
|
+
classification: 'user-facing',
|
|
70
|
+
build: buildPubgComparisonPresentation,
|
|
71
|
+
render: renderComparison,
|
|
72
|
+
},
|
|
73
|
+
pubg_get_match: {
|
|
74
|
+
classification: 'user-facing',
|
|
75
|
+
build: buildPubgMatchDetailPresentation,
|
|
76
|
+
render: renderMatchDetail,
|
|
77
|
+
},
|
|
78
|
+
pubg_get_review_facts: {
|
|
79
|
+
classification: 'user-facing',
|
|
80
|
+
build: buildPubgPresentation,
|
|
81
|
+
render: renderReview,
|
|
82
|
+
},
|
|
83
|
+
pubg_get_period_review: {
|
|
84
|
+
classification: 'user-facing',
|
|
85
|
+
build: buildPubgPresentation,
|
|
86
|
+
render: renderPeriodReview,
|
|
87
|
+
},
|
|
88
|
+
pubg_query_team_damage: {
|
|
89
|
+
classification: 'user-facing',
|
|
90
|
+
build: buildPubgTeamDamagePresentation,
|
|
91
|
+
render: renderTeamDamage,
|
|
92
|
+
},
|
|
93
|
+
pubg_prefetch_telemetry: {
|
|
94
|
+
classification: 'scheduled',
|
|
95
|
+
build: buildPubgStatusPresentation,
|
|
96
|
+
render: renderStatus,
|
|
97
|
+
},
|
|
98
|
+
pubg_telemetry_sync_report: {
|
|
99
|
+
classification: 'scheduled',
|
|
100
|
+
build: buildPubgStatusPresentation,
|
|
101
|
+
render: renderStatus,
|
|
102
|
+
},
|
|
103
|
+
};
|
|
104
|
+
export const PUBG_USER_FACING_TOOLS = Object.entries(PUBG_PRESENTATION_REGISTRY)
|
|
105
|
+
.filter(([, registration]) => registration.classification === 'user-facing')
|
|
106
|
+
.map(([name]) => name);
|
|
107
|
+
export function buildPubgToolPresentation(toolName, input, options = {}) {
|
|
108
|
+
const registration = PUBG_PRESENTATION_REGISTRY[toolName];
|
|
109
|
+
const enriched = { ...input, toolName };
|
|
110
|
+
if (!registration) {
|
|
111
|
+
const presentation = buildPubgStatusPresentation({
|
|
112
|
+
...enriched,
|
|
113
|
+
status: input.status ?? 'error',
|
|
114
|
+
error: {
|
|
115
|
+
code: 'presentation_mapping_missing',
|
|
116
|
+
reason: `No presentation mapping for ${toolName}`,
|
|
117
|
+
},
|
|
118
|
+
});
|
|
119
|
+
return { presentation, displayText: renderPubgStatus(presentation, options) };
|
|
120
|
+
}
|
|
121
|
+
const presentation = registration.build(enriched);
|
|
122
|
+
return { presentation, displayText: registration.render(presentation, options) };
|
|
123
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { PubgStatsPresentation } from '../contracts/pubg.js';
|
|
2
|
+
import type { SessionReviewPresentation } from '../contracts/session-review.js';
|
|
3
|
+
/**
|
|
4
|
+
* The once-a-day group message for one business day (06:00 to 06:00): the same rich 战绩 card a 昨日战绩 query gets,
|
|
5
|
+
* then the day's trend and conclusions from the session review, in Kurisu's voice, ending with the share link.
|
|
6
|
+
* Everything is deterministic; the voice lines are picked from the numbers.
|
|
7
|
+
*
|
|
8
|
+
* The text is Markdown: OpenClaw's WhatsApp send path parses it and re-renders it as WhatsApp formatting, where
|
|
9
|
+
* `**bold**` becomes WhatsApp *bold* and a single `*x*` would become _italic_. So bold is always `**…**`, and the
|
|
10
|
+
* WhatsApp client's own limits are respected on top of that: emoji stay outside the markers, a bold span is followed
|
|
11
|
+
* by a space, a newline or the end (a colon at most), and only the key facts are bold.
|
|
12
|
+
*/
|
|
13
|
+
export interface DailyReviewInput {
|
|
14
|
+
review: SessionReviewPresentation;
|
|
15
|
+
/** The pubg_query_stats presentation for the same business day; null leaves the card out. */
|
|
16
|
+
stats: PubgStatsPresentation | null;
|
|
17
|
+
/** Share page link; required, the daily review is never sent without one. */
|
|
18
|
+
link: string;
|
|
19
|
+
timezone: string;
|
|
20
|
+
now: Date;
|
|
21
|
+
}
|
|
22
|
+
export declare function renderDailyReview(input: DailyReviewInput): string;
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import { assertValid } from '../validation/validate.js';
|
|
2
|
+
import { validateSessionReviewPresentation } from '../validation/session-review.js';
|
|
3
|
+
import { renderPubgStats } from './pubg.js';
|
|
4
|
+
import { sessionMapName, sessionPlacement, sessionPlacementStrip } from './session-review.js';
|
|
5
|
+
function localDay(value, timezone) {
|
|
6
|
+
return new Intl.DateTimeFormat('zh-CN', {
|
|
7
|
+
timeZone: timezone,
|
|
8
|
+
month: 'long',
|
|
9
|
+
day: 'numeric',
|
|
10
|
+
weekday: 'long',
|
|
11
|
+
}).format(new Date(value));
|
|
12
|
+
}
|
|
13
|
+
function clock(value, timezone) {
|
|
14
|
+
const parts = Object.fromEntries(new Intl.DateTimeFormat('en-US', {
|
|
15
|
+
timeZone: timezone,
|
|
16
|
+
month: '2-digit',
|
|
17
|
+
day: '2-digit',
|
|
18
|
+
hour: '2-digit',
|
|
19
|
+
minute: '2-digit',
|
|
20
|
+
hourCycle: 'h23',
|
|
21
|
+
})
|
|
22
|
+
.formatToParts(new Date(value))
|
|
23
|
+
.map((part) => [part.type, part.value]));
|
|
24
|
+
return `${parts.month}/${parts.day} ${parts.hour}:${parts.minute}`;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* The 战绩 card as the chat renders it, thinned for the daily message: names, the card title, the team totals and each
|
|
28
|
+
* player's K/D stay bold; the volume line and the rest of the personal line are plain, titles included.
|
|
29
|
+
*/
|
|
30
|
+
function thinCard(card) {
|
|
31
|
+
return card
|
|
32
|
+
.split('\n')
|
|
33
|
+
.map((line) => {
|
|
34
|
+
if (line.startsWith('• 个人数据:')) {
|
|
35
|
+
const plain = line.replace(/\*\*/gu, '').replace(/KD (\d+(?:\.\d+)?)/u, '**KD $1**');
|
|
36
|
+
return plain
|
|
37
|
+
.replace('• 个人数据:', '• 个人数据: ')
|
|
38
|
+
.replace(/,/gu, ' · ')
|
|
39
|
+
.replace(/: (\*\*KD [\d.]+\*\*) · /u, ': $1 · ');
|
|
40
|
+
}
|
|
41
|
+
if (line.startsWith('• '))
|
|
42
|
+
return line.replace(/\*\*/gu, '');
|
|
43
|
+
return line;
|
|
44
|
+
})
|
|
45
|
+
.join('\n');
|
|
46
|
+
}
|
|
47
|
+
function one(value) {
|
|
48
|
+
return value === null ? '?' : value.toFixed(1);
|
|
49
|
+
}
|
|
50
|
+
function opener(review) {
|
|
51
|
+
const { wins, avgPlacement, baselineAvgPlacement } = review.summary;
|
|
52
|
+
if (wins >= 2)
|
|
53
|
+
return `**昨天吃了 ${wins} 次鸡** —— 哼,我承认,这个数据确实不坏。`;
|
|
54
|
+
if (wins === 1)
|
|
55
|
+
return '**昨天吃到 1 次鸡** —— 别急着庆祝,先看看其他几局是怎么回事。';
|
|
56
|
+
if (avgPlacement !== null &&
|
|
57
|
+
baselineAvgPlacement !== null &&
|
|
58
|
+
avgPlacement <= baselineAvgPlacement - 2)
|
|
59
|
+
return `**场均名次 ${one(avgPlacement)}** —— 比你们平时的 ${one(baselineAvgPlacement)} 好。看来偶尔也会把我的话听进去嘛。`;
|
|
60
|
+
if (avgPlacement !== null &&
|
|
61
|
+
baselineAvgPlacement !== null &&
|
|
62
|
+
avgPlacement >= baselineAvgPlacement + 2)
|
|
63
|
+
return `**场均名次 ${one(avgPlacement)}** —— 比平时的 ${one(baselineAvgPlacement)} 差。不是运气问题,数据在下面,自己看。`;
|
|
64
|
+
return `**昨天一共 ${review.matchCount} 场排位** —— 数据我整理好了。别找借口,先看数字。`;
|
|
65
|
+
}
|
|
66
|
+
function metric(row, key) {
|
|
67
|
+
const raw = row.values[key];
|
|
68
|
+
const value = typeof raw === 'number' ? raw : typeof raw === 'string' ? Number(raw) : Number.NaN;
|
|
69
|
+
return Number.isFinite(value) ? value : null;
|
|
70
|
+
}
|
|
71
|
+
/** One line for the best and one for the weakest K/D of the day; nothing when fewer than two players have one. */
|
|
72
|
+
function remarks(stats) {
|
|
73
|
+
const rows = (stats?.rows ?? [])
|
|
74
|
+
.map((row) => ({ row, kd: metric(row, 'kd'), damage: metric(row, 'damage') }))
|
|
75
|
+
.filter((entry) => entry.kd !== null);
|
|
76
|
+
if (rows.length < 2)
|
|
77
|
+
return [];
|
|
78
|
+
rows.sort((left, right) => right.kd - left.kd || (right.damage ?? 0) - (left.damage ?? 0));
|
|
79
|
+
const best = rows[0];
|
|
80
|
+
const worst = rows.at(-1);
|
|
81
|
+
if (best.kd === worst.kd)
|
|
82
|
+
return [];
|
|
83
|
+
return [
|
|
84
|
+
`**${best.row.label}** · K/D ${best.kd.toFixed(2)} 全队最高——这次算你有点实力。`,
|
|
85
|
+
`**${worst.row.label}** · K/D ${worst.kd.toFixed(2)} 垫底……下次冲之前先想清楚,别把队友当垫背。`,
|
|
86
|
+
];
|
|
87
|
+
}
|
|
88
|
+
export function renderDailyReview(input) {
|
|
89
|
+
const review = assertValid(validateSessionReviewPresentation(input.review));
|
|
90
|
+
if (!/^https?:\/\/\S+$/u.test(input.link))
|
|
91
|
+
throw new Error('daily review needs a share link');
|
|
92
|
+
const { timezone } = input;
|
|
93
|
+
const maps = review.maps
|
|
94
|
+
.map((map) => map.count > 1 ? `${sessionMapName(map.mapName)}×${map.count}` : sessionMapName(map.mapName))
|
|
95
|
+
.join(' ');
|
|
96
|
+
const windowStart = input.stats?.sourceRange?.from
|
|
97
|
+
? Date.parse(input.stats.sourceRange.from)
|
|
98
|
+
: Date.parse(review.startAt);
|
|
99
|
+
const windowEnd = input.stats?.sourceRange?.to
|
|
100
|
+
? Date.parse(input.stats.sourceRange.to)
|
|
101
|
+
: Date.parse(review.endAt);
|
|
102
|
+
const sections = [
|
|
103
|
+
[
|
|
104
|
+
`🌅 **每日复盘 · ${localDay(windowStart, timezone)}**`,
|
|
105
|
+
`_${clock(windowStart, timezone)} → ${clock(windowEnd, timezone)} · ${review.matchCount} 场排位 · ${maps}_`,
|
|
106
|
+
],
|
|
107
|
+
[opener(review)],
|
|
108
|
+
];
|
|
109
|
+
if (input.stats) {
|
|
110
|
+
const options = {
|
|
111
|
+
timezone,
|
|
112
|
+
now: input.now.toISOString(),
|
|
113
|
+
chatEmphasis: true,
|
|
114
|
+
};
|
|
115
|
+
sections.push([
|
|
116
|
+
thinCard(renderPubgStats(input.stats, options)).replace(/^🏆 (.+)$/mu, '🏆 **$1**'),
|
|
117
|
+
]);
|
|
118
|
+
}
|
|
119
|
+
const lines = remarks(input.stats);
|
|
120
|
+
if (lines.length)
|
|
121
|
+
sections.push(['🗣️ **红莉栖点评**', ...lines]);
|
|
122
|
+
const baseline = review.summary.baselineAvgPlacement === null
|
|
123
|
+
? ''
|
|
124
|
+
: ` (你们平时 ${one(review.summary.baselineAvgPlacement)})`;
|
|
125
|
+
sections.push([
|
|
126
|
+
'🎮 **全天走势**',
|
|
127
|
+
`名次 ${sessionPlacementStrip(review.placements)}`,
|
|
128
|
+
`场均名次 **${one(review.summary.avgPlacement)}**${baseline} · **吃鸡 ${review.summary.wins}** · 前十 ${review.summary.top10} · 击倒 ${review.summary.teamKnocks}`,
|
|
129
|
+
]);
|
|
130
|
+
sections.push([`**一句话:${review.headline}**`]);
|
|
131
|
+
sections.push(review.findings.length
|
|
132
|
+
? ['**结论**', ...review.findings.map((finding, index) => `${index + 1}. ${finding.text}`)]
|
|
133
|
+
: ['**结论**', '各项都在你们平时的正常波动范围内,没有值得单独拎出来的问题。']);
|
|
134
|
+
if (review.matchCount > 1 && review.bestMatch)
|
|
135
|
+
sections.push([
|
|
136
|
+
`**最好一局** ${sessionPlacement(review.bestMatch.rank)} ${sessionMapName(review.bestMatch.mapName)} · ${review.bestMatch.text}`,
|
|
137
|
+
]);
|
|
138
|
+
if (review.matchCount > 1 && review.worstMatch)
|
|
139
|
+
sections.push([
|
|
140
|
+
`**最差一局** ${sessionPlacement(review.worstMatch.rank)} ${sessionMapName(review.worstMatch.mapName)} · ${review.worstMatch.text}`,
|
|
141
|
+
]);
|
|
142
|
+
if (review.suggestion)
|
|
143
|
+
sections.push([`**下次试试** ${review.suggestion}`]);
|
|
144
|
+
const coverage = review.coverage.telemetry === review.coverage.total
|
|
145
|
+
? `📎 ${review.coverage.total}/${review.coverage.total} 场有完整遥测`
|
|
146
|
+
: `📎 ${review.coverage.telemetry}/${review.coverage.total} 场有完整遥测,其余只按基础战绩`;
|
|
147
|
+
sections.push([coverage, '—— 红莉栖 · 每天 09:30 的业务日复盘', `🔗 ${input.link}`]);
|
|
148
|
+
return sections.map((section) => section.join('\n')).join('\n\n');
|
|
149
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { OwnerNotificationPresentation } from '../contracts/owner.js';
|
|
2
|
+
export interface OwnerNotificationRenderOptions {
|
|
3
|
+
timezone?: string;
|
|
4
|
+
now?: Date | string;
|
|
5
|
+
}
|
|
6
|
+
export declare function renderOwnerNotification(presentation: OwnerNotificationPresentation, options?: OwnerNotificationRenderOptions): string;
|