@cyanheads/browser-compat-mcp-server 0.1.5 → 0.2.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/AGENTS.md +10 -9
- package/CLAUDE.md +10 -9
- package/Dockerfile +77 -51
- package/README.md +30 -18
- package/THIRD_PARTY_NOTICES.md +5 -5
- package/changelog/0.2.x/0.2.0.md +40 -0
- package/changelog/0.2.x/0.2.1.md +41 -0
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/mcp-server/tools/definitions/browsercompat-check-baseline.tool.d.ts +4 -1
- package/dist/mcp-server/tools/definitions/browsercompat-check-baseline.tool.d.ts.map +1 -1
- package/dist/mcp-server/tools/definitions/browsercompat-check-baseline.tool.js +62 -30
- package/dist/mcp-server/tools/definitions/browsercompat-check-baseline.tool.js.map +1 -1
- package/dist/mcp-server/tools/definitions/browsercompat-compare-support.tool.d.ts +75 -3
- package/dist/mcp-server/tools/definitions/browsercompat-compare-support.tool.d.ts.map +1 -1
- package/dist/mcp-server/tools/definitions/browsercompat-compare-support.tool.js +422 -106
- package/dist/mcp-server/tools/definitions/browsercompat-compare-support.tool.js.map +1 -1
- package/dist/mcp-server/tools/definitions/browsercompat-get-feature.tool.d.ts +55 -13
- package/dist/mcp-server/tools/definitions/browsercompat-get-feature.tool.d.ts.map +1 -1
- package/dist/mcp-server/tools/definitions/browsercompat-get-feature.tool.js +129 -32
- package/dist/mcp-server/tools/definitions/browsercompat-get-feature.tool.js.map +1 -1
- package/dist/mcp-server/tools/definitions/browsercompat-list-reference.tool.d.ts.map +1 -1
- package/dist/mcp-server/tools/definitions/browsercompat-list-reference.tool.js +7 -6
- package/dist/mcp-server/tools/definitions/browsercompat-list-reference.tool.js.map +1 -1
- package/dist/mcp-server/tools/definitions/browsercompat-search-features.tool.d.ts.map +1 -1
- package/dist/mcp-server/tools/definitions/browsercompat-search-features.tool.js +38 -23
- package/dist/mcp-server/tools/definitions/browsercompat-search-features.tool.js.map +1 -1
- package/dist/mcp-server/tools/definitions/compat-shapes.d.ts +128 -16
- package/dist/mcp-server/tools/definitions/compat-shapes.d.ts.map +1 -1
- package/dist/mcp-server/tools/definitions/compat-shapes.js +193 -34
- package/dist/mcp-server/tools/definitions/compat-shapes.js.map +1 -1
- package/dist/services/baseline/baseline-service.d.ts +11 -3
- package/dist/services/baseline/baseline-service.d.ts.map +1 -1
- package/dist/services/baseline/baseline-service.js +29 -2
- package/dist/services/baseline/baseline-service.js.map +1 -1
- package/dist/services/baseline/types.d.ts +11 -0
- package/dist/services/baseline/types.d.ts.map +1 -1
- package/dist/services/bcd/bcd-service.d.ts +33 -12
- package/dist/services/bcd/bcd-service.d.ts.map +1 -1
- package/dist/services/bcd/bcd-service.js +201 -87
- package/dist/services/bcd/bcd-service.js.map +1 -1
- package/dist/services/bcd/bcd-text.d.ts +11 -0
- package/dist/services/bcd/bcd-text.d.ts.map +1 -0
- package/dist/services/bcd/bcd-text.js +127 -0
- package/dist/services/bcd/bcd-text.js.map +1 -0
- package/dist/services/bcd/types.d.ts +29 -4
- package/dist/services/bcd/types.d.ts.map +1 -1
- package/dist/services/data-version/data-version-service.d.ts.map +1 -1
- package/dist/services/data-version/data-version-service.js +4 -3
- package/dist/services/data-version/data-version-service.js.map +1 -1
- package/dist/services/search/search-service.d.ts +21 -7
- package/dist/services/search/search-service.d.ts.map +1 -1
- package/dist/services/search/search-service.js +117 -42
- package/dist/services/search/search-service.js.map +1 -1
- package/dist/services/targets/targets-service.d.ts +11 -6
- package/dist/services/targets/targets-service.d.ts.map +1 -1
- package/dist/services/targets/targets-service.js +12 -7
- package/dist/services/targets/targets-service.js.map +1 -1
- package/dist/services/targets/types.d.ts +9 -2
- package/dist/services/targets/types.d.ts.map +1 -1
- package/dist/utils/markdown-text.d.ts +11 -0
- package/dist/utils/markdown-text.d.ts.map +1 -0
- package/dist/utils/markdown-text.js +57 -0
- package/dist/utils/markdown-text.js.map +1 -0
- package/package.json +15 -15
- package/server.json +10 -24
|
@@ -1,17 +1,37 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @fileoverview Tool computing whether a set of web features clears an explicit
|
|
3
|
-
* browserslist target query
|
|
4
|
-
*
|
|
3
|
+
* browserslist target query. The whole query is evaluated on every call; the
|
|
4
|
+
* target rows behind the verdicts are returned one page of query targets at a
|
|
5
|
+
* time, and a target counts as evaluated only where compatibility data was
|
|
6
|
+
* actually read for it.
|
|
5
7
|
* @module mcp-server/tools/definitions/browsercompat-compare-support
|
|
6
8
|
*/
|
|
7
9
|
import { tool, z } from '@cyanheads/mcp-ts-core';
|
|
8
10
|
import { JsonRpcErrorCode } from '@cyanheads/mcp-ts-core/errors';
|
|
11
|
+
import { markdown } from '@cyanheads/mcp-ts-core/utils';
|
|
9
12
|
import { getBaselineService } from '../../../services/baseline/baseline-service.js';
|
|
10
13
|
import { resolveFeature } from '../../../services/baseline/feature-resolver.js';
|
|
11
14
|
import { getBcdService } from '../../../services/bcd/bcd-service.js';
|
|
12
15
|
import { DataVersionSchema, getDataVersion, renderDataVersion, } from '../../../services/data-version/data-version-service.js';
|
|
13
16
|
import { CANIUSE_ATTRIBUTION, getTargetsService } from '../../../services/targets/targets-service.js';
|
|
14
|
-
import {
|
|
17
|
+
import { markdownText } from '../../../utils/markdown-text.js';
|
|
18
|
+
import { batchCompatKeys, FEATURES_MAX, FEATURES_PER_CALL, formatBatchCompatKeys, formatOmittedFeatures, formatStatementParts, ResolvedAsSchema, STATEMENT_FIELDS, } from './compat-shapes.js';
|
|
19
|
+
/**
|
|
20
|
+
* Every way a target can fail a feature, from either support source. Defined
|
|
21
|
+
* once so every surface that names a failing verdict accepts the same members.
|
|
22
|
+
*/
|
|
23
|
+
const FailingVerdictSchema = z
|
|
24
|
+
.enum([
|
|
25
|
+
'partial',
|
|
26
|
+
'prefixed',
|
|
27
|
+
'flagged',
|
|
28
|
+
'removed',
|
|
29
|
+
'unsupported',
|
|
30
|
+
'preview_only',
|
|
31
|
+
'before_feature_support',
|
|
32
|
+
'no_feature_support',
|
|
33
|
+
])
|
|
34
|
+
.describe('Why this target failed. From a key: partial means the implementation does not meet the mandatory specified behavior, prefixed means it only ships under a vendor prefix or a different name, flagged means it only works behind a preference or runtime flag, removed means it shipped and was later removed before this target version, unsupported means it was never added, preview_only means it only works in a preview channel. From web-features’ feature-level support: before_feature_support means the target predates the release web-features lists for the feature, no_feature_support means web-features lists no release of this core browser for the feature — which also covers a feature it lists no release for at all, such as a discontinued one (mutation-events) that older releases shipped; call again with one of compat_keys for a key-level verdict on such a target.');
|
|
15
35
|
const FailingTargetSchema = z.object({
|
|
16
36
|
agent: z.string().describe('browserslist agent id the target came from.'),
|
|
17
37
|
version_token: z.string().describe('Version token browserslist produced for that agent.'),
|
|
@@ -20,9 +40,17 @@ const FailingTargetSchema = z.object({
|
|
|
20
40
|
.string()
|
|
21
41
|
.nullable()
|
|
22
42
|
.describe('browser-compat-data release the token mapped to, or null when it predates them all.'),
|
|
23
|
-
verdict:
|
|
24
|
-
|
|
25
|
-
|
|
43
|
+
verdict: FailingVerdictSchema,
|
|
44
|
+
...STATEMENT_FIELDS,
|
|
45
|
+
});
|
|
46
|
+
const FailingRangeSchema = z.object({
|
|
47
|
+
agent: z.string().describe('browserslist agent id of every target in the run.'),
|
|
48
|
+
newest: z.string().describe('Version token of the run’s first, newest target.'),
|
|
49
|
+
oldest: z
|
|
50
|
+
.string()
|
|
51
|
+
.describe('Version token of the run’s last, oldest target; equals newest for a run of one.'),
|
|
52
|
+
count: z.number().int().describe('Query targets in the run.'),
|
|
53
|
+
verdict: FailingVerdictSchema,
|
|
26
54
|
});
|
|
27
55
|
const ResolvedTargetSchema = z.object({
|
|
28
56
|
agent: z.string().describe('browserslist agent id.'),
|
|
@@ -36,13 +64,22 @@ const ResolvedTargetSchema = z.object({
|
|
|
36
64
|
.number()
|
|
37
65
|
.int()
|
|
38
66
|
.describe('Release ordinal used for comparison; -1 when the token predates every release.'),
|
|
67
|
+
evaluated: z
|
|
68
|
+
.boolean()
|
|
69
|
+
.describe('True when every compared feature has compatibility data for this target. False when at least one compared feature records nothing for its browser or has no feature-level data for it, or when no feature in the call was comparable — the target then also appears in unchecked_targets. Mapping onto a release is not evaluation.'),
|
|
39
70
|
});
|
|
40
71
|
const UncheckedTargetSchema = z.object({
|
|
41
72
|
agent: z.string().describe('browserslist agent id.'),
|
|
42
73
|
version_token: z.string().describe('Version token browserslist produced for that agent.'),
|
|
43
74
|
reason: z
|
|
44
|
-
.enum([
|
|
45
|
-
|
|
75
|
+
.enum([
|
|
76
|
+
'no_bcd_browser',
|
|
77
|
+
'unknown_version',
|
|
78
|
+
'no_bcd_data',
|
|
79
|
+
'no_feature_level_data',
|
|
80
|
+
'no_comparable_feature',
|
|
81
|
+
])
|
|
82
|
+
.describe('no_bcd_browser when the agent has no browser-compat-data counterpart, unknown_version when the token maps to no release, no_bcd_data when a compared key records nothing for that browser, no_feature_level_data when a feature judged on web-features’ feature-level support has no answer for the target — a browser outside the Baseline core set, or a release before a ≤ bound — so call again with one of its compat_keys for a key-level answer, no_comparable_feature when every entry in features was a miss or ambiguous so nothing was compared. In the top-level list a target unchecked by several compared features takes the reason of the first of them.'),
|
|
46
83
|
usage_percent: z.number().describe('Share of tracked global traffic this target covers.'),
|
|
47
84
|
});
|
|
48
85
|
const ResultSchema = z.object({
|
|
@@ -52,25 +89,71 @@ const ResultSchema = z.object({
|
|
|
52
89
|
name: z.string().optional().describe('web-features display name for the feature.'),
|
|
53
90
|
verdict: z
|
|
54
91
|
.enum(['clears', 'fails', 'inconclusive', 'miss', 'ambiguous'])
|
|
55
|
-
.describe('
|
|
92
|
+
.describe('Judged over the whole query, never over one page. fails when any evaluated target does not support the feature; inconclusive when nothing failed but at least one target in the query was not evaluated for this feature, including when none was; clears only when every target in the query was evaluated and supports it; miss when the entry did not resolve; ambiguous when the web-features id owns no browser-compat-data keys, so there is no support data to judge.'),
|
|
93
|
+
support_source: z
|
|
94
|
+
.enum(['bcd_key', 'web_features_feature'])
|
|
95
|
+
.optional()
|
|
96
|
+
.describe('What the verdict was judged on. bcd_key: one browser-compat-data key’s per-browser support. web_features_feature: for an id spanning more than one key, web-features’ own release per Baseline core browser for the feature as a whole — never a combination of its keys, and a key can differ from it either way; browsers outside the core set are then not evaluated. Present on every compared result.'),
|
|
56
97
|
failing_targets: z
|
|
57
98
|
.array(FailingTargetSchema.describe('A target this feature does not clear.'))
|
|
58
|
-
.describe('
|
|
99
|
+
.describe('The failing targets among the query targets on this page, with the verdict that caused each. A row judged on a key also carries the fields of the support statement behind its verdict — version_added, prefix, alternative_name, flags, and the rest — each only when that statement has it; an unsupported or preview_only row, and a row judged on web-features’ feature-level support, carry none. Empty on a page that holds none even when failing_total is above zero.'),
|
|
100
|
+
failing_total: z
|
|
101
|
+
.number()
|
|
102
|
+
.int()
|
|
103
|
+
.optional()
|
|
104
|
+
.describe('Failing targets across the whole query. Present when the feature was compared, as are the six fields after it.'),
|
|
105
|
+
failing_ranges: z
|
|
106
|
+
.array(FailingRangeSchema.describe('A run of consecutive failing query targets.'))
|
|
107
|
+
.optional()
|
|
108
|
+
.describe('Every failing target across the whole query, grouped into runs: consecutive query targets of one browserslist agent that fail with the same verdict, in query order — agents in browserslist’s order, newest run first. A run breaks at any target that passed or was not evaluated for this feature, so it spans only versions the query contains. The counts sum to failing_total, and the list is the same on every page. Empty when nothing failed.'),
|
|
109
|
+
evaluated_total: z
|
|
110
|
+
.number()
|
|
111
|
+
.int()
|
|
112
|
+
.optional()
|
|
113
|
+
.describe('Query targets this feature has compatibility data for, across the whole query.'),
|
|
114
|
+
evaluated_coverage_percent: z
|
|
115
|
+
.number()
|
|
116
|
+
.optional()
|
|
117
|
+
.describe('Share of tracked global traffic the targets evaluated for this feature cover.'),
|
|
118
|
+
unchecked_total: z
|
|
119
|
+
.number()
|
|
120
|
+
.int()
|
|
121
|
+
.optional()
|
|
122
|
+
.describe('Query targets not evaluated for this feature, across the whole query. evaluated_total plus unchecked_total is the number of targets in the query.'),
|
|
123
|
+
unchecked_coverage_percent: z
|
|
124
|
+
.number()
|
|
125
|
+
.optional()
|
|
126
|
+
.describe('Share of tracked global traffic the targets not evaluated for this feature cover.'),
|
|
127
|
+
unchecked_targets: z
|
|
128
|
+
.array(UncheckedTargetSchema.describe('A target this feature was not evaluated against.'))
|
|
129
|
+
.optional()
|
|
130
|
+
.describe('The targets not evaluated for this feature among the query targets on this page, each with its reason.'),
|
|
59
131
|
compat_keys: z
|
|
60
132
|
.array(z.string())
|
|
61
133
|
.optional()
|
|
62
|
-
.describe('
|
|
134
|
+
.describe('The browser-compat-data keys a web-features id owns, its first 10 in declaration order: present when the id spans more than one key and was judged on its feature-level support, and as an empty list on an ambiguous verdict. compat_keys_total counts all of them; call browsercompat_get_feature with the id for the rest. Call again with one of them for a key-level verdict that also covers non-core browsers.'),
|
|
135
|
+
compat_keys_total: z
|
|
136
|
+
.number()
|
|
137
|
+
.int()
|
|
138
|
+
.optional()
|
|
139
|
+
.describe('Every browser-compat-data key the id owns. Present with compat_keys.'),
|
|
63
140
|
guidance: z.string().optional().describe('What to do next on a miss or an ambiguous verdict.'),
|
|
64
141
|
});
|
|
142
|
+
/** Query targets one page covers at most; a larger target_limit is served at this size (D52). */
|
|
143
|
+
const TARGET_LIMIT_CAP = 10;
|
|
144
|
+
/** Hard ceiling on target_limit; values past it are rejected against the schema. */
|
|
145
|
+
const TARGET_LIMIT_MAX = 1000;
|
|
146
|
+
/** The browserslist token a target row came from. */
|
|
147
|
+
const tokenOf = (target) => `${target.agent} ${target.version_token}`.trim();
|
|
65
148
|
export const browsercompatCompareSupport = tool('browsercompat_compare_support', {
|
|
66
|
-
description: 'Compute whether a set of web features clears an explicit browserslist target query.
|
|
149
|
+
description: 'Compute whether a set of web features clears an explicit browserslist target query. Compares up to 20 features per call; up to 100 may be sent, and entries past the 20th come back unevaluated in omitted_features for the next call. Every call evaluates the whole query: each feature gets a verdict, the count of failing targets, those targets grouped into runs of consecutive query targets per browser in failing_ranges, and its own evaluated and unevaluated target counts with the share of tracked traffic each covers. The target rows behind those numbers — which release each target maps to, which targets were not evaluated and why, and the failing and unevaluated targets of each feature, a failing row carrying the prefix, alternative name, or flag behind its verdict — cover at most ten query targets per call; page through them with target_offset and target_limit, and the verdicts, coverage, and totals stay identical on every page. A target counts as evaluated only where compatibility data was read for it, so a feature clears only when every target in the query was evaluated and supports it, and is inconclusive otherwise — a query that includes a browser with no compatibility data, as "defaults" does, never clears. A BCD key is judged on its own per-browser support. A web-features id spanning several keys, such as grid, is judged on the release web-features lists for the feature as a whole in each Baseline core browser, as support_source says; its other browsers are not evaluated.',
|
|
67
150
|
annotations: { readOnlyHint: true, idempotentHint: true, openWorldHint: false },
|
|
68
151
|
input: z.object({
|
|
69
152
|
features: z
|
|
70
153
|
.array(z.string().min(1).max(200))
|
|
71
154
|
.min(1)
|
|
72
|
-
.max(
|
|
73
|
-
.describe('
|
|
155
|
+
.max(FEATURES_MAX)
|
|
156
|
+
.describe('Entries to compare, each a browser-compat-data key such as css.selectors.has or a web-features id such as has, 1 to 200 characters. The first 20 are compared per call; up to 100 are accepted, and entries past the 20th are returned unevaluated in omitted_features. More than 100 entries, or an empty or longer entry anywhere in the list, is rejected against this schema; a whitespace-only entry anywhere returns invalid_feature_input. Call browsercompat_search_features first for any entry whose key you do not already know.'),
|
|
74
157
|
targets: z
|
|
75
158
|
.string()
|
|
76
159
|
.min(1)
|
|
@@ -79,44 +162,96 @@ export const browsercompatCompareSupport = tool('browsercompat_compare_support',
|
|
|
79
162
|
resolve: z
|
|
80
163
|
.boolean()
|
|
81
164
|
.default(false)
|
|
82
|
-
.describe('When true, an entry that is neither a key nor an id falls back to the search index, such as "Container queries" or "Element.prototype.animate". Its best exact matches are accepted only when they name one feature: a single key resolves to that key and
|
|
165
|
+
.describe('When true, an entry that is neither a key nor an id falls back to the search index, such as "Container queries (size)" or "Element.prototype.animate". Its best exact matches are accepted only when they name one feature: a single key resolves to that key and is judged on it, several keys of one web-features feature resolve to the feature and are judged on its feature-level support with compat_keys, and matches spanning two features are a miss. Off by default so a typo returns a miss you can correct rather than a confident answer about the wrong feature.'),
|
|
166
|
+
target_offset: z
|
|
167
|
+
.number()
|
|
168
|
+
.int()
|
|
169
|
+
.min(0)
|
|
170
|
+
.default(0)
|
|
171
|
+
.describe('Zero-based position in the target list of the query at which this page of target rows starts. Pass the nextOffset of the previous response to continue. An offset at or past the number of targets returns the whole-query verdicts and totals with no target rows.'),
|
|
172
|
+
target_limit: z
|
|
173
|
+
.number()
|
|
174
|
+
.int()
|
|
175
|
+
.min(1)
|
|
176
|
+
.max(TARGET_LIMIT_MAX)
|
|
177
|
+
.default(TARGET_LIMIT_CAP)
|
|
178
|
+
.describe('How many query targets this page covers, at most 10 per call; a value from 11 to 1000 is served as 10, and the cap enrichment field reports the size applied. It bounds every list of target rows in the response and never the evaluation: verdicts, coverage, and totals always describe the whole query.'),
|
|
83
179
|
}),
|
|
84
180
|
output: z.object({
|
|
85
181
|
query_echo: z.string().describe('The targets query as the server parsed it.'),
|
|
182
|
+
comparable_features: z
|
|
183
|
+
.number()
|
|
184
|
+
.int()
|
|
185
|
+
.describe('How many entries in features were compared against the targets, on a key or on web-features’ feature-level support. A miss or an ambiguous entry is not comparable; at 0 nothing was evaluated.'),
|
|
86
186
|
targets_resolved: z
|
|
87
187
|
.array(ResolvedTargetSchema.describe('A target that mapped onto a concrete release.'))
|
|
88
|
-
.describe('
|
|
188
|
+
.describe('The mapping inventory for the query targets on this page: each target that maps onto a browser-compat-data release, and whether it was evaluated. A target with no mapping appears only in unchecked_targets.'),
|
|
189
|
+
targets_resolved_total: z
|
|
190
|
+
.number()
|
|
191
|
+
.int()
|
|
192
|
+
.describe('Query targets that map onto a browser-compat-data release, across every page.'),
|
|
193
|
+
evaluated_targets_total: z
|
|
194
|
+
.number()
|
|
195
|
+
.int()
|
|
196
|
+
.describe('Query targets evaluated for every compared feature, across every page. evaluated_targets_total plus unchecked_targets_total is the number of targets in the query.'),
|
|
89
197
|
unchecked_targets: z
|
|
90
198
|
.array(UncheckedTargetSchema.describe('A target that was not evaluated.'))
|
|
91
|
-
.describe('
|
|
199
|
+
.describe('The query targets on this page that were not evaluated for every compared feature, each with the reason.'),
|
|
200
|
+
unchecked_targets_total: z
|
|
201
|
+
.number()
|
|
202
|
+
.int()
|
|
203
|
+
.describe('Query targets not evaluated for every compared feature, across every page.'),
|
|
92
204
|
target_coverage_percent: z
|
|
93
205
|
.number()
|
|
94
|
-
.describe('Share of tracked global traffic the evaluated
|
|
206
|
+
.describe('Share of tracked global traffic covered by the targets evaluated for every compared feature; 0 when no feature was comparable.'),
|
|
95
207
|
unchecked_coverage_percent: z
|
|
96
208
|
.number()
|
|
97
|
-
.describe('Share of tracked global traffic the
|
|
209
|
+
.describe('Share of tracked global traffic covered by the targets counted in unchecked_targets_total.'),
|
|
98
210
|
results: z
|
|
99
|
-
.array(ResultSchema.describe('One result per
|
|
100
|
-
.describe('Per-feature verdicts
|
|
211
|
+
.array(ResultSchema.describe('One result per evaluated entry, in input order.'))
|
|
212
|
+
.describe('Per-feature verdicts and totals over the whole query for the first 20 entries, each with its own target rows for this page.'),
|
|
213
|
+
omitted_features: z
|
|
214
|
+
.array(z.string())
|
|
215
|
+
.optional()
|
|
216
|
+
.describe('Entries past the first 20, verbatim and in input order, that were not compared. Present only when the call sent more than 20; pass them as features in the next call.'),
|
|
101
217
|
all_clear: z
|
|
102
218
|
.boolean()
|
|
103
|
-
.describe('True only when every feature clears
|
|
219
|
+
.describe('True only when every feature clears, which requires every target in the query to have been evaluated for it — for a feature judged on web-features’ feature-level support, every target must be a Baseline core browser. Any entry in omitted_features forces false.'),
|
|
104
220
|
}),
|
|
105
221
|
enrichment: {
|
|
106
222
|
data_version: DataVersionSchema.describe('Vintage of each bundled dataset behind this answer.'),
|
|
107
|
-
totalCount: z.number().describe('Number of
|
|
223
|
+
totalCount: z.number().describe('Number of targets the query resolved to, across every page.'),
|
|
224
|
+
shown: z.number().describe('Number of query targets this page covers.'),
|
|
225
|
+
cap: z
|
|
226
|
+
.number()
|
|
227
|
+
.describe('The page size applied: target_limit, or 10 when target_limit was above 10.'),
|
|
228
|
+
truncated: z.boolean().describe('True when more query targets remain past this page.'),
|
|
229
|
+
nextOffset: z
|
|
230
|
+
.number()
|
|
231
|
+
.optional()
|
|
232
|
+
.describe('The target_offset of the next page. Present only while targets remain past this page.'),
|
|
108
233
|
attribution: z
|
|
109
234
|
.string()
|
|
110
235
|
.describe('Required attribution for the caniuse-derived coverage figures in this response.'),
|
|
111
236
|
uncheckedNotice: z
|
|
112
237
|
.string()
|
|
113
238
|
.optional()
|
|
114
|
-
.describe('
|
|
239
|
+
.describe('How many of the query targets were not evaluated for every compared feature, the agents they belong to, and their combined usage share.'),
|
|
240
|
+
offsetNotice: z
|
|
241
|
+
.string()
|
|
242
|
+
.optional()
|
|
243
|
+
.describe('Why this page carries no target rows, and the offsets that do.'),
|
|
115
244
|
},
|
|
116
245
|
enrichmentTrailer: {
|
|
117
246
|
data_version: { render: renderDataVersion },
|
|
118
|
-
|
|
119
|
-
|
|
247
|
+
totalCount: { render: (value) => `**Targets in query:** ${value}` },
|
|
248
|
+
shown: { render: (value) => `**Targets on this page:** ${value}` },
|
|
249
|
+
cap: { render: (value) => `**Page size (target_limit):** ${value}` },
|
|
250
|
+
truncated: { render: (value) => `**More targets remain:** ${value ? 'yes' : 'no'}` },
|
|
251
|
+
nextOffset: { render: (value) => `**Next page:** call again with target_offset ${value}` },
|
|
252
|
+
attribution: { render: (value) => `**Usage data:** ${markdownText(value)}` },
|
|
253
|
+
uncheckedNotice: { render: (value) => `**Not evaluated:** ${markdownText(value ?? '')}` },
|
|
254
|
+
offsetNotice: { render: (value) => `**Empty page:** ${value}` },
|
|
120
255
|
},
|
|
121
256
|
errors: [
|
|
122
257
|
{
|
|
@@ -135,7 +270,7 @@ export const browsercompatCompareSupport = tool('browsercompat_compare_support',
|
|
|
135
270
|
{
|
|
136
271
|
reason: 'invalid_feature_input',
|
|
137
272
|
code: JsonRpcErrorCode.ValidationError,
|
|
138
|
-
when: 'An entry in features is whitespace-only. An empty or over-200-character entry is rejected against the input schema instead.',
|
|
273
|
+
when: 'An entry in features is whitespace-only, including an entry past the 20th. An empty or over-200-character entry is rejected against the input schema instead.',
|
|
139
274
|
recovery: 'Replace the whitespace-only entry with a BCD key such as css.selectors.has or a web-features id such as has; use browsercompat_search_features to find one.',
|
|
140
275
|
},
|
|
141
276
|
],
|
|
@@ -150,26 +285,115 @@ export const browsercompatCompareSupport = tool('browsercompat_compare_support',
|
|
|
150
285
|
getBaselineService(),
|
|
151
286
|
getTargetsService(),
|
|
152
287
|
]);
|
|
153
|
-
const tokens = targets.queryTokens(input.targets
|
|
154
|
-
const { resolved, unchecked } = await targets.resolveTargets(tokens);
|
|
288
|
+
const tokens = targets.queryTokens(input.targets);
|
|
289
|
+
const { resolved, unchecked: unmapped } = await targets.resolveTargets(tokens);
|
|
155
290
|
/**
|
|
156
291
|
* Only a query with nothing left to evaluate is an error. A mapped agent
|
|
157
292
|
* whose version token does not resolve carries a per-token reason of its
|
|
158
293
|
* own, so it stays an ordinary response with the token in unchecked_targets
|
|
159
294
|
* — the same treatment it gets alongside a token that did resolve.
|
|
160
295
|
*/
|
|
161
|
-
if (resolved.length === 0 && !
|
|
162
|
-
const
|
|
163
|
-
throw ctx.fail('no_targets_resolved',
|
|
296
|
+
if (resolved.length === 0 && !unmapped.some((target) => target.reason === 'unknown_version')) {
|
|
297
|
+
const agents = [...new Set(unmapped.map((target) => target.agent))].join(', ');
|
|
298
|
+
throw ctx.fail('no_targets_resolved', unmapped.length === 0
|
|
164
299
|
? `"${input.targets}" matched no browser versions at all.`
|
|
165
|
-
: `"${input.targets}" resolved only to agents with no browser-compat-data counterpart: ${
|
|
166
|
-
}
|
|
167
|
-
const uncheckedByKey = new Map();
|
|
168
|
-
for (const target of unchecked) {
|
|
169
|
-
uncheckedByKey.set(`${target.agent} ${target.version_token} ${target.reason}`, target);
|
|
300
|
+
: `"${input.targets}" resolved only to agents with no browser-compat-data counterpart: ${agents}.`);
|
|
170
301
|
}
|
|
302
|
+
/** Every query target in browserslist order, whether or not it mapped onto a release. */
|
|
303
|
+
const byToken = new Map([...resolved, ...unmapped].map((target) => [tokenOf(target), target]));
|
|
304
|
+
const queryTargets = tokens
|
|
305
|
+
.map((token) => byToken.get(token))
|
|
306
|
+
.filter((target) => target !== undefined);
|
|
307
|
+
const pageSize = Math.min(input.target_limit, TARGET_LIMIT_CAP);
|
|
308
|
+
const onPage = new Set(tokens.slice(input.target_offset, input.target_offset + pageSize));
|
|
309
|
+
const isOnPage = (target) => onPage.has(tokenOf(target));
|
|
310
|
+
const usage = new Map();
|
|
311
|
+
/** A mapped target a comparison could not evaluate, reported the way an unmapped one is. */
|
|
312
|
+
const uncheckedRow = (target, reason) => {
|
|
313
|
+
const token = tokenOf(target);
|
|
314
|
+
let usagePercent = usage.get(token);
|
|
315
|
+
if (usagePercent === undefined) {
|
|
316
|
+
usagePercent = targets.coverage([token]);
|
|
317
|
+
usage.set(token, usagePercent);
|
|
318
|
+
}
|
|
319
|
+
return {
|
|
320
|
+
agent: target.agent,
|
|
321
|
+
version_token: target.version_token,
|
|
322
|
+
reason,
|
|
323
|
+
usage_percent: usagePercent,
|
|
324
|
+
};
|
|
325
|
+
};
|
|
326
|
+
/**
|
|
327
|
+
* Judge every query target with one support source. A target the source has
|
|
328
|
+
* no answer for is unchecked with that source's reason, never a failure.
|
|
329
|
+
* Failing targets are also grouped into runs as they arrive in query order:
|
|
330
|
+
* a run continues only across consecutive targets of one agent failing with
|
|
331
|
+
* one verdict, and any target that passed or went unevaluated ends it.
|
|
332
|
+
*/
|
|
333
|
+
const compare = (judge, unknownReason) => {
|
|
334
|
+
const failing = [];
|
|
335
|
+
const ranges = [];
|
|
336
|
+
const notEvaluated = [];
|
|
337
|
+
const evaluatedTokens = [];
|
|
338
|
+
let run;
|
|
339
|
+
for (const target of queryTargets) {
|
|
340
|
+
if ('reason' in target) {
|
|
341
|
+
notEvaluated.push(target);
|
|
342
|
+
run = undefined;
|
|
343
|
+
continue;
|
|
344
|
+
}
|
|
345
|
+
const { verdict, statement } = judge(target);
|
|
346
|
+
if (verdict === 'unknown') {
|
|
347
|
+
notEvaluated.push(uncheckedRow(target, unknownReason));
|
|
348
|
+
run = undefined;
|
|
349
|
+
continue;
|
|
350
|
+
}
|
|
351
|
+
evaluatedTokens.push(tokenOf(target));
|
|
352
|
+
if (verdict === 'supported') {
|
|
353
|
+
run = undefined;
|
|
354
|
+
continue;
|
|
355
|
+
}
|
|
356
|
+
failing.push({
|
|
357
|
+
agent: target.agent,
|
|
358
|
+
version_token: target.version_token,
|
|
359
|
+
bcd_browser: target.bcd_browser,
|
|
360
|
+
bcd_version: target.bcd_version,
|
|
361
|
+
verdict,
|
|
362
|
+
...statement,
|
|
363
|
+
});
|
|
364
|
+
if (run?.agent === target.agent && run.verdict === verdict) {
|
|
365
|
+
run.oldest = target.version_token;
|
|
366
|
+
run.count += 1;
|
|
367
|
+
}
|
|
368
|
+
else {
|
|
369
|
+
run = {
|
|
370
|
+
agent: target.agent,
|
|
371
|
+
newest: target.version_token,
|
|
372
|
+
oldest: target.version_token,
|
|
373
|
+
count: 1,
|
|
374
|
+
verdict,
|
|
375
|
+
};
|
|
376
|
+
ranges.push(run);
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
return {
|
|
380
|
+
failing,
|
|
381
|
+
ranges,
|
|
382
|
+
unchecked: notEvaluated,
|
|
383
|
+
evaluatedTotal: evaluatedTokens.length,
|
|
384
|
+
evaluatedCoverage: targets.coverage(evaluatedTokens),
|
|
385
|
+
uncheckedCoverage: targets.coverage(notEvaluated.map(tokenOf)),
|
|
386
|
+
};
|
|
387
|
+
};
|
|
388
|
+
/**
|
|
389
|
+
* Keyed by compat key, or by feature id for a feature-level comparison (keys
|
|
390
|
+
* always contain a dot and ids never do), so a repeated entry is evaluated once.
|
|
391
|
+
*/
|
|
392
|
+
const comparisons = new Map();
|
|
171
393
|
const results = [];
|
|
172
|
-
|
|
394
|
+
const omitted = input.features.slice(FEATURES_PER_CALL);
|
|
395
|
+
let comparableFeatures = 0;
|
|
396
|
+
for (const entry of input.features.slice(0, FEATURES_PER_CALL)) {
|
|
173
397
|
const query = entry.trim();
|
|
174
398
|
const resolution = await resolveFeature(query, {
|
|
175
399
|
resolve: input.resolve,
|
|
@@ -191,8 +415,35 @@ export const browsercompatCompareSupport = tool('browsercompat_compare_support',
|
|
|
191
415
|
const name = featureId === null ? undefined : baseline.feature(featureId)?.name;
|
|
192
416
|
const key = resolvedAs.bcd_key;
|
|
193
417
|
const leaf = key === null ? undefined : bcd.leaf(key);
|
|
194
|
-
|
|
195
|
-
|
|
418
|
+
const compatKeys = resolution.compat_keys ?? [];
|
|
419
|
+
/** An id spanning several keys is judged on web-features' own feature-level support. */
|
|
420
|
+
const featureLevel = featureId !== null && compatKeys.length > 0
|
|
421
|
+
? baseline.featureSupport(featureId)
|
|
422
|
+
: undefined;
|
|
423
|
+
const subject = leaf !== undefined
|
|
424
|
+
? {
|
|
425
|
+
source: 'bcd_key',
|
|
426
|
+
cacheKey: `${key}`,
|
|
427
|
+
unknownReason: 'no_bcd_data',
|
|
428
|
+
judge: (target) => {
|
|
429
|
+
const { verdict, detail } = bcd.supportAt(leaf, target.bcd_browser, target.bcd_release_index);
|
|
430
|
+
if (verdict === 'supported' || verdict === 'unknown')
|
|
431
|
+
return { verdict };
|
|
432
|
+
const { notes: _notes, impl_url: _implUrl, ...statement } = detail;
|
|
433
|
+
return { verdict, statement };
|
|
434
|
+
},
|
|
435
|
+
}
|
|
436
|
+
: featureLevel !== undefined
|
|
437
|
+
? {
|
|
438
|
+
source: 'web_features_feature',
|
|
439
|
+
cacheKey: `${featureId}`,
|
|
440
|
+
unknownReason: 'no_feature_level_data',
|
|
441
|
+
judge: (target) => ({
|
|
442
|
+
verdict: bcd.featureSupportAt(featureLevel, baseline.coreBrowserIds, target.bcd_browser, target.bcd_release_index),
|
|
443
|
+
}),
|
|
444
|
+
}
|
|
445
|
+
: undefined;
|
|
446
|
+
if (subject === undefined) {
|
|
196
447
|
results.push({
|
|
197
448
|
input: entry,
|
|
198
449
|
found: true,
|
|
@@ -200,118 +451,183 @@ export const browsercompatCompareSupport = tool('browsercompat_compare_support',
|
|
|
200
451
|
...(name === undefined ? {} : { name }),
|
|
201
452
|
verdict: 'ambiguous',
|
|
202
453
|
failing_targets: [],
|
|
203
|
-
|
|
204
|
-
guidance:
|
|
205
|
-
? `"${featureId ?? query}" is tracked by web-features but owns no browser-compat-data keys, so there is no per-browser support to compare. Call browsercompat_check_baseline for its Baseline state.`
|
|
206
|
-
: `"${featureId ?? query}" spans ${compatKeys.length} browser-compat-data keys, so no single support verdict applies. Call browsercompat_compare_support again with one of compat_keys.`,
|
|
454
|
+
...batchCompatKeys(compatKeys),
|
|
455
|
+
guidance: `"${featureId ?? query}" is tracked by web-features but owns no browser-compat-data keys, so there is no per-browser support to compare. Call browsercompat_check_baseline for its Baseline state.`,
|
|
207
456
|
});
|
|
208
457
|
continue;
|
|
209
458
|
}
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
const evaluation = bcd.supportAt(leaf, target.bcd_browser, target.bcd_release_index);
|
|
215
|
-
if (evaluation.verdict === 'supported')
|
|
216
|
-
continue;
|
|
217
|
-
if (evaluation.verdict === 'unknown') {
|
|
218
|
-
inconclusive = true;
|
|
219
|
-
const uncheckedKey = `${target.agent} ${target.version_token} no_bcd_data`;
|
|
220
|
-
if (!uncheckedByKey.has(uncheckedKey)) {
|
|
221
|
-
uncheckedByKey.set(uncheckedKey, {
|
|
222
|
-
agent: target.agent,
|
|
223
|
-
version_token: target.version_token,
|
|
224
|
-
reason: 'no_bcd_data',
|
|
225
|
-
usage_percent: targets.coverage([`${target.agent} ${target.version_token}`]),
|
|
226
|
-
});
|
|
227
|
-
}
|
|
228
|
-
continue;
|
|
229
|
-
}
|
|
230
|
-
failing.push({
|
|
231
|
-
agent: target.agent,
|
|
232
|
-
version_token: target.version_token,
|
|
233
|
-
bcd_browser: target.bcd_browser,
|
|
234
|
-
bcd_version: target.bcd_version,
|
|
235
|
-
verdict: evaluation.verdict,
|
|
236
|
-
});
|
|
459
|
+
let comparison = comparisons.get(subject.cacheKey);
|
|
460
|
+
if (comparison === undefined) {
|
|
461
|
+
comparison = compare(subject.judge, subject.unknownReason);
|
|
462
|
+
comparisons.set(subject.cacheKey, comparison);
|
|
237
463
|
}
|
|
464
|
+
comparableFeatures += 1;
|
|
238
465
|
results.push({
|
|
239
466
|
input: entry,
|
|
240
467
|
found: true,
|
|
241
468
|
resolved_as: resolvedAs,
|
|
242
469
|
...(name === undefined ? {} : { name }),
|
|
243
|
-
|
|
244
|
-
|
|
470
|
+
support_source: subject.source,
|
|
471
|
+
verdict: comparison.failing.length > 0
|
|
472
|
+
? 'fails'
|
|
473
|
+
: comparison.unchecked.length > 0
|
|
474
|
+
? 'inconclusive'
|
|
475
|
+
: 'clears',
|
|
476
|
+
failing_targets: comparison.failing.filter(isOnPage),
|
|
477
|
+
failing_total: comparison.failing.length,
|
|
478
|
+
failing_ranges: comparison.ranges,
|
|
479
|
+
evaluated_total: comparison.evaluatedTotal,
|
|
480
|
+
evaluated_coverage_percent: comparison.evaluatedCoverage,
|
|
481
|
+
unchecked_total: comparison.unchecked.length,
|
|
482
|
+
unchecked_coverage_percent: comparison.uncheckedCoverage,
|
|
483
|
+
unchecked_targets: comparison.unchecked.filter(isOnPage),
|
|
484
|
+
...(subject.source === 'web_features_feature' ? batchCompatKeys(compatKeys) : {}),
|
|
245
485
|
});
|
|
246
486
|
}
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
487
|
+
/**
|
|
488
|
+
* A target is evaluated for the call only when every compared feature has
|
|
489
|
+
* data for it: the aggregate evaluated set is the intersection of the
|
|
490
|
+
* per-feature sets, and everything else in the query is unchecked. A mapped
|
|
491
|
+
* target several features left unchecked takes the reason of the earliest
|
|
492
|
+
* compared result — comparisons are keyed in first-seen input order.
|
|
493
|
+
*/
|
|
494
|
+
const withoutData = new Map();
|
|
495
|
+
for (const comparison of comparisons.values()) {
|
|
496
|
+
for (const target of comparison.unchecked) {
|
|
497
|
+
const token = tokenOf(target);
|
|
498
|
+
if ((target.reason === 'no_bcd_data' || target.reason === 'no_feature_level_data') &&
|
|
499
|
+
!withoutData.has(token)) {
|
|
500
|
+
withoutData.set(token, target.reason);
|
|
501
|
+
}
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
const uncheckedTargets = queryTargets.flatMap((target) => {
|
|
505
|
+
if ('reason' in target)
|
|
506
|
+
return [target];
|
|
507
|
+
if (comparableFeatures === 0)
|
|
508
|
+
return [uncheckedRow(target, 'no_comparable_feature')];
|
|
509
|
+
const reason = withoutData.get(tokenOf(target));
|
|
510
|
+
return reason === undefined ? [] : [uncheckedRow(target, reason)];
|
|
511
|
+
});
|
|
512
|
+
const uncheckedTokens = new Set(uncheckedTargets.map(tokenOf));
|
|
513
|
+
const evaluatedTokens = tokens.filter((token) => !uncheckedTokens.has(token));
|
|
514
|
+
const uncheckedCoverage = targets.coverage([...uncheckedTokens]);
|
|
515
|
+
const shown = onPage.size;
|
|
516
|
+
const nextOffset = input.target_offset + shown;
|
|
517
|
+
const truncated = nextOffset < tokens.length;
|
|
518
|
+
ctx.enrich({ totalCount: tokens.length, shown, cap: pageSize, truncated });
|
|
519
|
+
if (truncated)
|
|
520
|
+
ctx.enrich({ nextOffset });
|
|
521
|
+
if (shown === 0) {
|
|
255
522
|
ctx.enrich({
|
|
256
|
-
|
|
523
|
+
offsetNotice: `target_offset ${input.target_offset} is at or past the ${tokens.length} targets in the query. Call again with a target_offset below ${tokens.length}, or omit it for the first page.`,
|
|
524
|
+
});
|
|
525
|
+
}
|
|
526
|
+
if (comparableFeatures === 0) {
|
|
527
|
+
ctx.enrich({
|
|
528
|
+
uncheckedNotice: `No feature was comparable, so none of the ${tokens.length} target versions was evaluated (${uncheckedCoverage}% of tracked traffic). Resolve the miss and ambiguous entries and call again.`,
|
|
529
|
+
});
|
|
530
|
+
}
|
|
531
|
+
else if (uncheckedTargets.length > 0) {
|
|
532
|
+
const agents = [...new Set(uncheckedTargets.map((target) => target.agent))].join(', ');
|
|
533
|
+
ctx.enrich({
|
|
534
|
+
uncheckedNotice: `${uncheckedTargets.length} of ${tokens.length} target versions were not evaluated for every compared feature (${agents}), together ${uncheckedCoverage}% of tracked traffic. No feature is reported as clearing them.`,
|
|
257
535
|
});
|
|
258
536
|
}
|
|
259
537
|
ctx.log.debug('Compared support', {
|
|
260
538
|
targets: input.targets,
|
|
261
|
-
|
|
262
|
-
|
|
539
|
+
queryTargets: tokens.length,
|
|
540
|
+
mapped: resolved.length,
|
|
541
|
+
evaluated: evaluatedTokens.length,
|
|
542
|
+
offset: input.target_offset,
|
|
543
|
+
shown,
|
|
544
|
+
omitted: omitted.length,
|
|
263
545
|
});
|
|
264
546
|
return {
|
|
265
547
|
query_echo: input.targets.trim(),
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
548
|
+
comparable_features: comparableFeatures,
|
|
549
|
+
targets_resolved: resolved
|
|
550
|
+
.filter(isOnPage)
|
|
551
|
+
.map((target) => ({ ...target, evaluated: !uncheckedTokens.has(tokenOf(target)) })),
|
|
552
|
+
targets_resolved_total: resolved.length,
|
|
553
|
+
evaluated_targets_total: evaluatedTokens.length,
|
|
554
|
+
unchecked_targets: uncheckedTargets.filter(isOnPage),
|
|
555
|
+
unchecked_targets_total: uncheckedTargets.length,
|
|
556
|
+
target_coverage_percent: targets.coverage(evaluatedTokens),
|
|
557
|
+
unchecked_coverage_percent: uncheckedCoverage,
|
|
270
558
|
results,
|
|
271
|
-
|
|
559
|
+
...(omitted.length === 0 ? {} : { omitted_features: omitted }),
|
|
560
|
+
all_clear: omitted.length === 0 && results.every((result) => result.verdict === 'clears'),
|
|
272
561
|
};
|
|
273
562
|
},
|
|
274
563
|
format: (result) => {
|
|
275
564
|
const clearing = result.results.filter((item) => item.verdict === 'clears').length;
|
|
565
|
+
const queryTotal = result.evaluated_targets_total + result.unchecked_targets_total;
|
|
276
566
|
const lines = [
|
|
277
|
-
`# ${clearing} of ${result.results.length} features clears
|
|
278
|
-
|
|
279
|
-
|
|
567
|
+
`# ${clearing} of ${result.results.length} features clears ${markdown().inlineCode(result.query_echo).build()}`,
|
|
568
|
+
...(result.comparable_features === 0
|
|
569
|
+
? ['No feature was comparable, so no target version was evaluated.']
|
|
570
|
+
: []),
|
|
571
|
+
`Evaluated for every compared feature: ${result.evaluated_targets_total} of ${queryTotal} target versions (${result.target_coverage_percent}% of tracked traffic) · not evaluated: ${result.unchecked_targets_total} (${result.unchecked_coverage_percent}%)`,
|
|
572
|
+
`Compared ${result.comparable_features} of ${result.results.length} features · ${result.targets_resolved_total} of ${queryTotal} target versions map to a browser-compat-data release`,
|
|
280
573
|
`**all_clear:** ${result.all_clear}`,
|
|
574
|
+
...(result.omitted_features ? [formatOmittedFeatures(result.omitted_features)] : []),
|
|
281
575
|
'',
|
|
282
576
|
];
|
|
283
577
|
for (const item of result.results) {
|
|
284
|
-
lines.push(`**${item.verdict}** ${item.name ?? item.input} (input ${item.input}, found ${item.found})`);
|
|
578
|
+
lines.push(`**${item.verdict}** ${markdownText(item.name ?? item.input)} (input ${markdownText(item.input)}, found ${item.found})`);
|
|
285
579
|
if (item.resolved_as) {
|
|
286
|
-
lines.push(` - resolved: "${item.resolved_as.input}" → bcd_key ${item.resolved_as.bcd_key ?? 'none'} · baseline_id ${item.resolved_as.baseline_id ?? 'none'} · via ${item.resolved_as.resolved_via}`);
|
|
580
|
+
lines.push(` - resolved: "${markdownText(item.resolved_as.input)}" → bcd_key ${markdownText(item.resolved_as.bcd_key ?? 'none')} · baseline_id ${markdownText(item.resolved_as.baseline_id ?? 'none')} · via ${item.resolved_as.resolved_via}`);
|
|
581
|
+
}
|
|
582
|
+
if (item.support_source) {
|
|
583
|
+
lines.push(item.support_source === 'bcd_key'
|
|
584
|
+
? ' - support_source: bcd_key'
|
|
585
|
+
: ' - support_source: web_features_feature — web-features’ release per Baseline core browser for the feature as a whole');
|
|
586
|
+
}
|
|
587
|
+
if (item.unchecked_targets) {
|
|
588
|
+
lines.push(` - evaluated on ${item.evaluated_total} of ${queryTotal} target versions (${item.evaluated_coverage_percent}% of tracked traffic) · failing ${item.failing_total} · not evaluated ${item.unchecked_total} (${item.unchecked_coverage_percent}%)`, ` - on this page: ${item.failing_targets.length} of ${item.failing_total} failing, ${item.unchecked_targets.length} of ${item.unchecked_total} not evaluated`);
|
|
589
|
+
}
|
|
590
|
+
if (item.failing_ranges) {
|
|
591
|
+
const runs = item.failing_ranges.map((range) => `${markdownText(range.agent)} ${markdownText(range.newest)}${range.oldest === range.newest ? '' : ` to ${markdownText(range.oldest)}`}: ${range.count} ${range.verdict}`);
|
|
592
|
+
lines.push(` - failing_ranges (whole query): ${runs.length === 0 ? 'none' : runs.join('; ')}`);
|
|
287
593
|
}
|
|
288
594
|
for (const target of item.failing_targets) {
|
|
289
|
-
|
|
595
|
+
const statement = formatStatementParts(target);
|
|
596
|
+
lines.push(` - fails on ${markdownText(target.agent)} ${markdownText(target.version_token)} → ${markdownText(target.bcd_browser)} ${markdownText(target.bcd_version ?? 'older than all releases')} (${target.verdict})${statement.length === 0 ? '' : ` · ${statement.join(' · ')}`}`);
|
|
597
|
+
}
|
|
598
|
+
for (const target of item.unchecked_targets ?? []) {
|
|
599
|
+
lines.push(` - not evaluated on ${markdownText(target.agent)} ${markdownText(target.version_token)} (${target.reason}, ${target.usage_percent}% usage)`);
|
|
290
600
|
}
|
|
291
601
|
if (item.compat_keys) {
|
|
292
|
-
lines.push(` - compat_keys: ${item.compat_keys.
|
|
602
|
+
lines.push(` - compat_keys: ${formatBatchCompatKeys(item.compat_keys, item.compat_keys_total ?? item.compat_keys.length, item.resolved_as?.baseline_id ?? item.input)}`);
|
|
293
603
|
}
|
|
294
604
|
if (item.guidance)
|
|
295
|
-
lines.push(` - ${item.guidance}`);
|
|
605
|
+
lines.push(` - ${markdownText(item.guidance)}`);
|
|
296
606
|
}
|
|
297
|
-
lines.push('',
|
|
298
|
-
if (result.
|
|
299
|
-
lines.push('No target version
|
|
607
|
+
lines.push('', `## Targets mapped to a release — ${result.targets_resolved.length} of ${result.targets_resolved_total} on this page`);
|
|
608
|
+
if (result.targets_resolved_total === 0) {
|
|
609
|
+
lines.push('No target version maps to a browser-compat-data release.');
|
|
610
|
+
}
|
|
611
|
+
else if (result.targets_resolved.length === 0) {
|
|
612
|
+
lines.push(`None of the ${result.targets_resolved_total} mapped target versions is on this page.`);
|
|
300
613
|
}
|
|
301
614
|
else {
|
|
302
|
-
lines.push('| Target | browser-compat-data |', '
|
|
615
|
+
lines.push('| Target | browser-compat-data | Evaluated for every compared feature |', '|:--|:--|:--|');
|
|
303
616
|
for (const target of result.targets_resolved) {
|
|
304
|
-
lines.push(`| ${target.agent} ${target.version_token} | ${target.bcd_browser} ${target.bcd_version ?? 'older than all releases'} (index ${target.bcd_release_index}) |`);
|
|
617
|
+
lines.push(`| ${markdownText(target.agent)} ${markdownText(target.version_token)} | ${markdownText(target.bcd_browser)} ${markdownText(target.bcd_version ?? 'older than all releases')} (index ${target.bcd_release_index}) | ${target.evaluated ? 'yes' : 'no'} |`);
|
|
305
618
|
}
|
|
306
619
|
}
|
|
307
|
-
lines.push('',
|
|
308
|
-
if (result.
|
|
309
|
-
lines.push('Every
|
|
620
|
+
lines.push('', `## Not evaluated for every compared feature — ${result.unchecked_targets.length} of ${result.unchecked_targets_total} on this page`);
|
|
621
|
+
if (result.unchecked_targets_total === 0) {
|
|
622
|
+
lines.push('Every target version was evaluated for every compared feature.');
|
|
623
|
+
}
|
|
624
|
+
else if (result.unchecked_targets.length === 0) {
|
|
625
|
+
lines.push(`None of the ${result.unchecked_targets_total} unevaluated target versions is on this page.`);
|
|
310
626
|
}
|
|
311
627
|
else {
|
|
312
628
|
lines.push('| Target | Reason | Usage |', '|:--|:--|:--|');
|
|
313
629
|
for (const target of result.unchecked_targets) {
|
|
314
|
-
lines.push(`| ${target.agent} ${target.version_token} | ${target.reason} | ${target.usage_percent}% |`);
|
|
630
|
+
lines.push(`| ${markdownText(target.agent)} ${markdownText(target.version_token)} | ${target.reason} | ${target.usage_percent}% |`);
|
|
315
631
|
}
|
|
316
632
|
}
|
|
317
633
|
return [{ type: 'text', text: lines.join('\n') }];
|