@mergesignal/shared 0.3.0 → 0.4.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/dist/deriveScanNarrative.js +1 -1
- package/dist/engineWireRegression.test.js +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/narrativeParity.test.js +19 -18
- package/dist/presentGitHubPrComment.d.ts +3 -4
- package/dist/presentGitHubPrComment.d.ts.map +1 -1
- package/dist/presentGitHubPrComment.js +15 -61
- package/dist/presentation/compose/narrativeCompose.d.ts +16 -0
- package/dist/presentation/compose/narrativeCompose.d.ts.map +1 -0
- package/dist/presentation/compose/narrativeCompose.js +167 -0
- package/dist/presentation/dto/githubAndCliPresentation.d.ts +53 -0
- package/dist/presentation/dto/githubAndCliPresentation.d.ts.map +1 -0
- package/dist/presentation/dto/githubAndCliPresentation.js +1 -0
- package/dist/presentation/dto/scanCardPresentation.d.ts +25 -0
- package/dist/presentation/dto/scanCardPresentation.d.ts.map +1 -0
- package/dist/presentation/dto/scanCardPresentation.js +1 -0
- package/dist/presentation/dto/scanDetailsPresentation.d.ts +111 -0
- package/dist/presentation/dto/scanDetailsPresentation.d.ts.map +1 -0
- package/dist/presentation/dto/scanDetailsPresentation.js +1 -0
- package/dist/presentation/dto/types.d.ts +24 -0
- package/dist/presentation/dto/types.d.ts.map +1 -0
- package/dist/presentation/dto/types.js +22 -0
- package/dist/presentation/fixtures/scanResultFixtures.d.ts +5 -0
- package/dist/presentation/fixtures/scanResultFixtures.d.ts.map +1 -0
- package/dist/presentation/fixtures/scanResultFixtures.js +83 -0
- package/dist/presentation/index.d.ts +25 -0
- package/dist/presentation/index.d.ts.map +1 -0
- package/dist/presentation/index.js +13 -0
- package/dist/presentation/orchestration/buildScanCardPresentation.d.ts +11 -0
- package/dist/presentation/orchestration/buildScanCardPresentation.d.ts.map +1 -0
- package/dist/presentation/orchestration/buildScanCardPresentation.js +44 -0
- package/dist/presentation/orchestration/buildScanDetailsPresentation.d.ts +14 -0
- package/dist/presentation/orchestration/buildScanDetailsPresentation.d.ts.map +1 -0
- package/dist/presentation/orchestration/buildScanDetailsPresentation.js +19 -0
- package/dist/presentation/orchestration/buildScanPresentationBundle.d.ts +15 -0
- package/dist/presentation/orchestration/buildScanPresentationBundle.d.ts.map +1 -0
- package/dist/presentation/orchestration/buildScanPresentationBundle.js +23 -0
- package/dist/presentation/orchestration/scanPresentationBundle.d.ts +15 -0
- package/dist/presentation/orchestration/scanPresentationBundle.d.ts.map +1 -0
- package/dist/presentation/orchestration/scanPresentationBundle.js +1 -0
- package/dist/presentation/presentation.test.d.ts +2 -0
- package/dist/presentation/presentation.test.d.ts.map +1 -0
- package/dist/presentation/presentation.test.js +95 -0
- package/dist/presentation/presenters/presentCliScanSummary.d.ts +6 -0
- package/dist/presentation/presenters/presentCliScanSummary.d.ts.map +1 -0
- package/dist/presentation/presenters/presentCliScanSummary.js +30 -0
- package/dist/presentation/presenters/presentGitHubCheckRun.d.ts +8 -0
- package/dist/presentation/presenters/presentGitHubCheckRun.d.ts.map +1 -0
- package/dist/presentation/presenters/presentGitHubCheckRun.js +32 -0
- package/dist/presentation/presenters/presentGitHubPrComment.d.ts +4 -0
- package/dist/presentation/presenters/presentGitHubPrComment.d.ts.map +1 -0
- package/dist/presentation/presenters/presentGitHubPrComment.js +40 -0
- package/dist/presentation/presenters/presentPipelineScanCard.d.ts +3 -0
- package/dist/presentation/presenters/presentPipelineScanCard.d.ts.map +1 -0
- package/dist/presentation/presenters/presentPipelineScanCard.js +23 -0
- package/dist/presentation/presenters/presentScanCard.d.ts +7 -0
- package/dist/presentation/presenters/presentScanCard.d.ts.map +1 -0
- package/dist/presentation/presenters/presentScanCard.js +43 -0
- package/dist/presentation/presenters/presentScanDetails.d.ts +9 -0
- package/dist/presentation/presenters/presentScanDetails.d.ts.map +1 -0
- package/dist/presentation/presenters/presentScanDetails.js +177 -0
- package/dist/presentation/profile/derivePresentationProfile.d.ts +12 -0
- package/dist/presentation/profile/derivePresentationProfile.d.ts.map +1 -0
- package/dist/presentation/profile/derivePresentationProfile.js +86 -0
- package/dist/presentation/profile/presentationProfile.d.ts +9 -0
- package/dist/presentation/profile/presentationProfile.d.ts.map +1 -0
- package/dist/presentation/profile/presentationProfile.js +1 -0
- package/dist/presentation/render/renderCliScanSummaryText.d.ts +3 -0
- package/dist/presentation/render/renderCliScanSummaryText.d.ts.map +1 -0
- package/dist/presentation/render/renderCliScanSummaryText.js +30 -0
- package/dist/presentation/render/renderGitHubCheckRunMarkdown.d.ts +3 -0
- package/dist/presentation/render/renderGitHubCheckRunMarkdown.d.ts.map +1 -0
- package/dist/presentation/render/renderGitHubCheckRunMarkdown.js +23 -0
- package/dist/presentation/render/renderGitHubPrCommentMarkdown.d.ts +3 -0
- package/dist/presentation/render/renderGitHubPrCommentMarkdown.d.ts.map +1 -0
- package/dist/presentation/render/renderGitHubPrCommentMarkdown.js +24 -0
- package/dist/scanCardSummary.d.ts +4 -35
- package/dist/scanCardSummary.d.ts.map +1 -1
- package/dist/scanCardSummary.js +12 -63
- package/dist/scanCardSummary.test.js +56 -75
- package/dist/scanDetailViewModel.d.ts +1 -0
- package/dist/scanDetailViewModel.d.ts.map +1 -1
- package/dist/scanDetailViewModel.js +1 -1
- package/dist/scanSurfaceCopy.d.ts +25 -0
- package/dist/scanSurfaceCopy.d.ts.map +1 -1
- package/dist/scanSurfaceCopy.js +25 -0
- package/package.json +1 -1
- package/dist/presentScanCardSummary.d.ts +0 -16
- package/dist/presentScanCardSummary.d.ts.map +0 -1
- package/dist/presentScanCardSummary.js +0 -212
|
@@ -1,212 +0,0 @@
|
|
|
1
|
-
import { isCatalogPhrase, phraseForFamily, } from "./cardObservationCatalog.js";
|
|
2
|
-
import { aggregateFindingCounts, deriveRiskIndexBand, SCAN_CARD_SCANNING_SUMMARY, } from "./scanCardSummary.js";
|
|
3
|
-
import { deriveCardExposureDisplay, } from "./formatCardExposureDisplay.js";
|
|
4
|
-
import { formatCardAreaLabels } from "./formatCardAreaLabels.js";
|
|
5
|
-
import { composeContextLineFromFacts, composeVerificationPrompt, formatBlastRadiusDetailLine, formatChangedPackagesShort, formatFrameworksSummary, formatUsageSummaryLine, labelBlastRadiusLevel, labelReachabilityKind, labelRuntimeSurface, } from "./narrativePresentation.js";
|
|
6
|
-
import { normalizeGeneratedText, normalizeGeneratedTextNullable, } from "./normalizeGeneratedText.js";
|
|
7
|
-
import { MERGE_POSTURE_LABEL } from "./riskVocabulary.js";
|
|
8
|
-
import { scanSurfaceCopy } from "./scanSurfaceCopy.js";
|
|
9
|
-
function formatAffectedAreaLabels(facts) {
|
|
10
|
-
const ordered = [];
|
|
11
|
-
for (const area of facts.affectedAreas) {
|
|
12
|
-
const formatted = formatCardAreaLabels([area.label], 1);
|
|
13
|
-
if (formatted[0])
|
|
14
|
-
ordered.push(formatted[0]);
|
|
15
|
-
if (ordered.length >= 2)
|
|
16
|
-
break;
|
|
17
|
-
}
|
|
18
|
-
return ordered;
|
|
19
|
-
}
|
|
20
|
-
function selectPrimaryInsight(facts) {
|
|
21
|
-
const changedGuidance = facts.reviewerGuidance.find((g) => g.scope === "changed" && g.message.trim());
|
|
22
|
-
if (changedGuidance)
|
|
23
|
-
return changedGuidance.message.trim();
|
|
24
|
-
const insight = facts.reviewerGuidance.find((g) => g.kind === "insight" && g.message.trim());
|
|
25
|
-
if (insight)
|
|
26
|
-
return insight.message.trim();
|
|
27
|
-
return null;
|
|
28
|
-
}
|
|
29
|
-
function selectSecondaryLines(facts, exclude) {
|
|
30
|
-
const lines = [];
|
|
31
|
-
for (const g of facts.reviewerGuidance) {
|
|
32
|
-
const msg = g.message.trim();
|
|
33
|
-
if (!msg || msg === exclude)
|
|
34
|
-
continue;
|
|
35
|
-
lines.push(msg);
|
|
36
|
-
if (lines.length >= 2)
|
|
37
|
-
break;
|
|
38
|
-
}
|
|
39
|
-
return lines;
|
|
40
|
-
}
|
|
41
|
-
function repositoryContextPhrases(facts, max) {
|
|
42
|
-
const phrases = [];
|
|
43
|
-
const seen = new Set();
|
|
44
|
-
for (const ctx of facts.repositoryContext) {
|
|
45
|
-
const phrase = phraseForFamily(ctx.family);
|
|
46
|
-
if (seen.has(phrase))
|
|
47
|
-
continue;
|
|
48
|
-
seen.add(phrase);
|
|
49
|
-
phrases.push(phrase);
|
|
50
|
-
if (phrases.length >= max)
|
|
51
|
-
break;
|
|
52
|
-
}
|
|
53
|
-
return phrases;
|
|
54
|
-
}
|
|
55
|
-
function buildLegacyObservations(facts, primaryInsight, repoPhraseCap) {
|
|
56
|
-
const repoPhrases = repositoryContextPhrases(facts, repoPhraseCap);
|
|
57
|
-
const secondary = selectSecondaryLines(facts, primaryInsight);
|
|
58
|
-
if (primaryInsight) {
|
|
59
|
-
return {
|
|
60
|
-
operationalObservations: repoPhrases.slice(0, 1),
|
|
61
|
-
supportingLine: repoPhrases[0] && repoPhrases[0] !== primaryInsight
|
|
62
|
-
? repoPhrases[0]
|
|
63
|
-
: (secondary[0] ?? null),
|
|
64
|
-
};
|
|
65
|
-
}
|
|
66
|
-
if (repoPhrases.length === 0) {
|
|
67
|
-
return { operationalObservations: [], supportingLine: null };
|
|
68
|
-
}
|
|
69
|
-
return {
|
|
70
|
-
operationalObservations: repoPhrases.slice(0, repoPhraseCap),
|
|
71
|
-
supportingLine: repoPhrases.length === 1 ? (secondary[0] ?? null) : null,
|
|
72
|
-
};
|
|
73
|
-
}
|
|
74
|
-
function normalizeCardSummary(summary) {
|
|
75
|
-
return {
|
|
76
|
-
...summary,
|
|
77
|
-
headline: normalizeGeneratedText(summary.headline),
|
|
78
|
-
summaryLine: normalizeGeneratedTextNullable(summary.summaryLine),
|
|
79
|
-
supportingLine: normalizeGeneratedTextNullable(summary.supportingLine),
|
|
80
|
-
changedPackagesDisplay: normalizeGeneratedTextNullable(summary.changedPackagesDisplay),
|
|
81
|
-
runtimeSurfaceLabel: normalizeGeneratedTextNullable(summary.runtimeSurfaceLabel),
|
|
82
|
-
reachabilityLabel: normalizeGeneratedTextNullable(summary.reachabilityLabel),
|
|
83
|
-
blastRadiusLabel: normalizeGeneratedTextNullable(summary.blastRadiusLabel),
|
|
84
|
-
primaryInsight: normalizeGeneratedTextNullable(summary.primaryInsight),
|
|
85
|
-
structuralOnlyDisclaimer: normalizeGeneratedTextNullable(summary.structuralOnlyDisclaimer),
|
|
86
|
-
usageSummary: normalizeGeneratedTextNullable(summary.usageSummary),
|
|
87
|
-
verificationLine: normalizeGeneratedTextNullable(summary.verificationLine),
|
|
88
|
-
blastRadiusDetail: normalizeGeneratedTextNullable(summary.blastRadiusDetail),
|
|
89
|
-
frameworksSummary: normalizeGeneratedTextNullable(summary.frameworksSummary),
|
|
90
|
-
affectedAreas: summary.affectedAreas.map((a) => normalizeGeneratedText(a)),
|
|
91
|
-
topAffectedAreas: summary.topAffectedAreas.map((a) => normalizeGeneratedText(a)),
|
|
92
|
-
operationalObservations: summary.operationalObservations.map((p) => {
|
|
93
|
-
const normalized = normalizeGeneratedText(p);
|
|
94
|
-
return isCatalogPhrase(normalized) ? normalized : p;
|
|
95
|
-
}),
|
|
96
|
-
};
|
|
97
|
-
}
|
|
98
|
-
/**
|
|
99
|
-
* Dashboard card presentation DTO from consumer-agnostic facts.
|
|
100
|
-
*/
|
|
101
|
-
export function presentScanCardSummary(facts, options = {}) {
|
|
102
|
-
const pipelineStatus = options.pipelineStatus ?? "done";
|
|
103
|
-
const emptyPresentationFields = {
|
|
104
|
-
narrativeMode: facts.availability.mode,
|
|
105
|
-
codeIntelligenceAvailable: facts.availability.codeIntelligenceAvailable,
|
|
106
|
-
changedPackagesDisplay: null,
|
|
107
|
-
runtimeSurfaceLabel: null,
|
|
108
|
-
reachabilityLabel: null,
|
|
109
|
-
blastRadiusLabel: null,
|
|
110
|
-
affectedAreas: [],
|
|
111
|
-
primaryInsight: null,
|
|
112
|
-
structuralOnlyDisclaimer: null,
|
|
113
|
-
usageSummary: null,
|
|
114
|
-
verificationLine: null,
|
|
115
|
-
blastRadiusDetail: null,
|
|
116
|
-
frameworksSummary: null,
|
|
117
|
-
};
|
|
118
|
-
if (pipelineStatus === "queued" || pipelineStatus === "running") {
|
|
119
|
-
return normalizeCardSummary({
|
|
120
|
-
mergePosture: null,
|
|
121
|
-
riskIndex: null,
|
|
122
|
-
riskIndexBand: null,
|
|
123
|
-
headline: scanSurfaceCopy.pipeline.scanRunning,
|
|
124
|
-
summaryLine: SCAN_CARD_SCANNING_SUMMARY,
|
|
125
|
-
findingCounts: null,
|
|
126
|
-
topAffectedAreas: [],
|
|
127
|
-
operationalObservations: [],
|
|
128
|
-
supportingLine: null,
|
|
129
|
-
...emptyPresentationFields,
|
|
130
|
-
});
|
|
131
|
-
}
|
|
132
|
-
if (pipelineStatus === "failed") {
|
|
133
|
-
return normalizeCardSummary({
|
|
134
|
-
mergePosture: null,
|
|
135
|
-
riskIndex: null,
|
|
136
|
-
riskIndexBand: null,
|
|
137
|
-
headline: scanSurfaceCopy.pipeline.analysisIncomplete,
|
|
138
|
-
summaryLine: null,
|
|
139
|
-
findingCounts: null,
|
|
140
|
-
topAffectedAreas: [],
|
|
141
|
-
operationalObservations: [],
|
|
142
|
-
supportingLine: null,
|
|
143
|
-
...emptyPresentationFields,
|
|
144
|
-
});
|
|
145
|
-
}
|
|
146
|
-
const posture = facts.mergePosture;
|
|
147
|
-
const riskIndex = facts.riskIndex;
|
|
148
|
-
const riskIndexBand = deriveRiskIndexBand(riskIndex);
|
|
149
|
-
const headline = posture
|
|
150
|
-
? MERGE_POSTURE_LABEL[posture]
|
|
151
|
-
: scanSurfaceCopy.checkRun.mergePostureUnavailable;
|
|
152
|
-
const findingCounts = options.findings
|
|
153
|
-
? aggregateFindingCounts(options.findings)
|
|
154
|
-
: null;
|
|
155
|
-
const prIntelligence = facts.availability.mode === "pr_intelligence" ||
|
|
156
|
-
facts.availability.tiersPresent.tier1;
|
|
157
|
-
const changedPackagesDisplay = formatChangedPackagesShort(facts, 2);
|
|
158
|
-
const runtimeSurfaceLabel = labelRuntimeSurface(facts);
|
|
159
|
-
const reachabilityLabel = labelReachabilityKind(facts);
|
|
160
|
-
const blastRadiusLabel = labelBlastRadiusLevel(facts);
|
|
161
|
-
const affectedAreas = formatAffectedAreaLabels(facts);
|
|
162
|
-
const contextLine = composeContextLineFromFacts(facts, {
|
|
163
|
-
includePathSample: prIntelligence,
|
|
164
|
-
maxAreas: 2,
|
|
165
|
-
});
|
|
166
|
-
const structuralOnlyDisclaimer = facts.availability.mode === "graph_fallback" &&
|
|
167
|
-
!facts.availability.tiersPresent.tier1
|
|
168
|
-
? scanSurfaceCopy.narrativeCard.structuralOnlyDisclaimer
|
|
169
|
-
: null;
|
|
170
|
-
const insightMessage = selectPrimaryInsight(facts);
|
|
171
|
-
const primaryInsight = insightMessage ??
|
|
172
|
-
(facts.availability.mode !== "graph_fallback" ? contextLine : null);
|
|
173
|
-
const usageSummary = prIntelligence ? formatUsageSummaryLine(facts, 1) : null;
|
|
174
|
-
const verificationLine = prIntelligence
|
|
175
|
-
? composeVerificationPrompt(facts)
|
|
176
|
-
: null;
|
|
177
|
-
const blastRadiusDetail = prIntelligence
|
|
178
|
-
? formatBlastRadiusDetailLine(facts, 1)
|
|
179
|
-
: null;
|
|
180
|
-
const frameworksSummary = prIntelligence
|
|
181
|
-
? formatFrameworksSummary(facts, 2)
|
|
182
|
-
: null;
|
|
183
|
-
const repoPhraseCap = prIntelligence ? 0 : 3;
|
|
184
|
-
const { operationalObservations, supportingLine } = buildLegacyObservations(facts, primaryInsight, repoPhraseCap);
|
|
185
|
-
return normalizeCardSummary({
|
|
186
|
-
mergePosture: posture,
|
|
187
|
-
riskIndex,
|
|
188
|
-
riskIndexBand,
|
|
189
|
-
headline,
|
|
190
|
-
summaryLine: null,
|
|
191
|
-
findingCounts,
|
|
192
|
-
topAffectedAreas: affectedAreas,
|
|
193
|
-
operationalObservations,
|
|
194
|
-
supportingLine,
|
|
195
|
-
narrativeMode: facts.availability.mode,
|
|
196
|
-
codeIntelligenceAvailable: facts.availability.codeIntelligenceAvailable,
|
|
197
|
-
changedPackagesDisplay,
|
|
198
|
-
runtimeSurfaceLabel,
|
|
199
|
-
reachabilityLabel,
|
|
200
|
-
blastRadiusLabel,
|
|
201
|
-
affectedAreas,
|
|
202
|
-
primaryInsight,
|
|
203
|
-
structuralOnlyDisclaimer,
|
|
204
|
-
usageSummary,
|
|
205
|
-
verificationLine,
|
|
206
|
-
blastRadiusDetail,
|
|
207
|
-
frameworksSummary,
|
|
208
|
-
});
|
|
209
|
-
}
|
|
210
|
-
export function exposureFromFacts(facts) {
|
|
211
|
-
return deriveCardExposureDisplay(facts.riskIndex) ?? null;
|
|
212
|
-
}
|