@cyanheads/browser-compat-mcp-server 0.2.0 → 0.3.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/AGENTS.md +23 -10
- package/CLAUDE.md +23 -10
- package/Dockerfile +20 -7
- package/README.md +33 -36
- package/THIRD_PARTY_NOTICES.md +5 -6
- package/changelog/0.2.x/0.2.1.md +41 -0
- package/changelog/0.3.x/0.3.0.md +39 -0
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/mcp-server/tools/definitions/browsercompat-check-baseline.tool.d.ts +5 -2
- 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 +48 -21
- 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 +44 -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 +228 -87
- 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 +44 -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 +67 -15
- package/dist/mcp-server/tools/definitions/browsercompat-get-feature.tool.js.map +1 -1
- package/dist/mcp-server/tools/definitions/browsercompat-list-reference.tool.js +2 -2
- 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 +14 -6
- 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 +179 -23
- 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 +31 -12
- package/dist/services/bcd/bcd-service.d.ts.map +1 -1
- package/dist/services/bcd/bcd-service.js +157 -75
- package/dist/services/bcd/bcd-service.js.map +1 -1
- package/dist/services/bcd/types.d.ts +29 -4
- package/dist/services/bcd/types.d.ts.map +1 -1
- package/dist/services/search/search-service.d.ts +20 -2
- package/dist/services/search/search-service.d.ts.map +1 -1
- package/dist/services/search/search-service.js +115 -20
- package/dist/services/search/search-service.js.map +1 -1
- package/dist/services/targets/targets-service.d.ts +7 -10
- package/dist/services/targets/targets-service.d.ts.map +1 -1
- package/dist/services/targets/targets-service.js +18 -10
- package/dist/services/targets/targets-service.js.map +1 -1
- package/dist/services/targets/types.d.ts +6 -4
- package/dist/services/targets/types.d.ts.map +1 -1
- package/package.json +16 -15
- package/server.json +10 -24
- package/skills/browser-compat-guide/SKILL.md +48 -0
|
@@ -15,7 +15,23 @@ import { getBcdService } from '../../../services/bcd/bcd-service.js';
|
|
|
15
15
|
import { DataVersionSchema, getDataVersion, renderDataVersion, } from '../../../services/data-version/data-version-service.js';
|
|
16
16
|
import { CANIUSE_ATTRIBUTION, getTargetsService } from '../../../services/targets/targets-service.js';
|
|
17
17
|
import { markdownText } from '../../../utils/markdown-text.js';
|
|
18
|
-
import { ResolvedAsSchema } from './compat-shapes.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.');
|
|
19
35
|
const FailingTargetSchema = z.object({
|
|
20
36
|
agent: z.string().describe('browserslist agent id the target came from.'),
|
|
21
37
|
version_token: z.string().describe('Version token browserslist produced for that agent.'),
|
|
@@ -24,9 +40,17 @@ const FailingTargetSchema = z.object({
|
|
|
24
40
|
.string()
|
|
25
41
|
.nullable()
|
|
26
42
|
.describe('browser-compat-data release the token mapped to, or null when it predates them all.'),
|
|
27
|
-
verdict:
|
|
28
|
-
|
|
29
|
-
|
|
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,
|
|
30
54
|
});
|
|
31
55
|
const ResolvedTargetSchema = z.object({
|
|
32
56
|
agent: z.string().describe('browserslist agent id.'),
|
|
@@ -42,15 +66,21 @@ const ResolvedTargetSchema = z.object({
|
|
|
42
66
|
.describe('Release ordinal used for comparison; -1 when the token predates every release.'),
|
|
43
67
|
evaluated: z
|
|
44
68
|
.boolean()
|
|
45
|
-
.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 when no feature in the call was comparable — the target then also appears in unchecked_targets. Mapping onto a release is not evaluation.'),
|
|
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.'),
|
|
46
70
|
});
|
|
47
71
|
const UncheckedTargetSchema = z.object({
|
|
48
72
|
agent: z.string().describe('browserslist agent id.'),
|
|
49
73
|
version_token: z.string().describe('Version token browserslist produced for that agent.'),
|
|
50
74
|
reason: z
|
|
51
|
-
.enum([
|
|
52
|
-
|
|
53
|
-
|
|
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.'),
|
|
83
|
+
usage_percent: z.number().describe('Percentage points of global traffic this target covers.'),
|
|
54
84
|
});
|
|
55
85
|
const ResultSchema = z.object({
|
|
56
86
|
input: z.string().describe('The feature string as the caller sent it.'),
|
|
@@ -59,15 +89,23 @@ const ResultSchema = z.object({
|
|
|
59
89
|
name: z.string().optional().describe('web-features display name for the feature.'),
|
|
60
90
|
verdict: z
|
|
61
91
|
.enum(['clears', 'fails', 'inconclusive', 'miss', 'ambiguous'])
|
|
62
|
-
.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 id
|
|
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.'),
|
|
63
97
|
failing_targets: z
|
|
64
98
|
.array(FailingTargetSchema.describe('A target this feature does not clear.'))
|
|
65
|
-
.describe('The failing targets among the query targets on this page, with the verdict that caused each. Empty on a page that holds none even when failing_total is above zero.'),
|
|
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.'),
|
|
66
100
|
failing_total: z
|
|
67
101
|
.number()
|
|
68
102
|
.int()
|
|
69
103
|
.optional()
|
|
70
|
-
.describe('Failing targets across the whole query. Present when the feature was compared, as are the
|
|
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.'),
|
|
71
109
|
evaluated_total: z
|
|
72
110
|
.number()
|
|
73
111
|
.int()
|
|
@@ -76,7 +114,7 @@ const ResultSchema = z.object({
|
|
|
76
114
|
evaluated_coverage_percent: z
|
|
77
115
|
.number()
|
|
78
116
|
.optional()
|
|
79
|
-
.describe('
|
|
117
|
+
.describe('Percentage points of global traffic the targets evaluated for this feature cover.'),
|
|
80
118
|
unchecked_total: z
|
|
81
119
|
.number()
|
|
82
120
|
.int()
|
|
@@ -85,7 +123,7 @@ const ResultSchema = z.object({
|
|
|
85
123
|
unchecked_coverage_percent: z
|
|
86
124
|
.number()
|
|
87
125
|
.optional()
|
|
88
|
-
.describe('
|
|
126
|
+
.describe('Percentage points of global traffic the targets not evaluated for this feature cover.'),
|
|
89
127
|
unchecked_targets: z
|
|
90
128
|
.array(UncheckedTargetSchema.describe('A target this feature was not evaluated against.'))
|
|
91
129
|
.optional()
|
|
@@ -93,29 +131,38 @@ const ResultSchema = z.object({
|
|
|
93
131
|
compat_keys: z
|
|
94
132
|
.array(z.string())
|
|
95
133
|
.optional()
|
|
96
|
-
.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.'),
|
|
97
140
|
guidance: z.string().optional().describe('What to do next on a miss or an ambiguous verdict.'),
|
|
98
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;
|
|
99
146
|
/** The browserslist token a target row came from. */
|
|
100
147
|
const tokenOf = (target) => `${target.agent} ${target.version_token}`.trim();
|
|
101
148
|
export const browsercompatCompareSupport = tool('browsercompat_compare_support', {
|
|
102
|
-
description: 'Compute whether a set of web features clears an explicit browserslist target query. Every call evaluates the whole query: each feature gets a verdict, the count of failing targets, and its own evaluated and unevaluated target counts with the
|
|
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 percentage points of global 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.',
|
|
103
150
|
annotations: { readOnlyHint: true, idempotentHint: true, openWorldHint: false },
|
|
104
151
|
input: z.object({
|
|
105
152
|
features: z
|
|
106
153
|
.array(z.string().min(1).max(200))
|
|
107
154
|
.min(1)
|
|
108
|
-
.max(
|
|
109
|
-
.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.'),
|
|
110
157
|
targets: z
|
|
111
158
|
.string()
|
|
112
159
|
.min(1)
|
|
113
160
|
.max(500)
|
|
114
|
-
.describe('A browserslist query, for example "defaults" or "> 0.5%, last 2 versions", 1 to 500 characters.
|
|
161
|
+
.describe('A self-contained browserslist query, for example "defaults" or "> 0.5%, last 2 versions", 1 to 500 characters. Config packages and custom configuration are unsupported; local config discovery is disabled.'),
|
|
115
162
|
resolve: z
|
|
116
163
|
.boolean()
|
|
117
164
|
.default(false)
|
|
118
|
-
.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
|
|
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.'),
|
|
119
166
|
target_offset: z
|
|
120
167
|
.number()
|
|
121
168
|
.int()
|
|
@@ -126,16 +173,16 @@ export const browsercompatCompareSupport = tool('browsercompat_compare_support',
|
|
|
126
173
|
.number()
|
|
127
174
|
.int()
|
|
128
175
|
.min(1)
|
|
129
|
-
.max(
|
|
130
|
-
.default(
|
|
131
|
-
.describe('How many query targets this page covers,
|
|
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.'),
|
|
132
179
|
}),
|
|
133
180
|
output: z.object({
|
|
134
181
|
query_echo: z.string().describe('The targets query as the server parsed it.'),
|
|
135
182
|
comparable_features: z
|
|
136
183
|
.number()
|
|
137
184
|
.int()
|
|
138
|
-
.describe('How many entries in features were compared against the targets. A miss or an ambiguous entry is not comparable; at 0 nothing was evaluated.'),
|
|
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.'),
|
|
139
186
|
targets_resolved: z
|
|
140
187
|
.array(ResolvedTargetSchema.describe('A target that mapped onto a concrete release.'))
|
|
141
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.'),
|
|
@@ -156,22 +203,28 @@ export const browsercompatCompareSupport = tool('browsercompat_compare_support',
|
|
|
156
203
|
.describe('Query targets not evaluated for every compared feature, across every page.'),
|
|
157
204
|
target_coverage_percent: z
|
|
158
205
|
.number()
|
|
159
|
-
.describe('
|
|
206
|
+
.describe('Percentage points of global traffic covered by the targets evaluated for every compared feature; 0 when no feature was comparable.'),
|
|
160
207
|
unchecked_coverage_percent: z
|
|
161
208
|
.number()
|
|
162
|
-
.describe('
|
|
209
|
+
.describe('Percentage points of global traffic covered by the targets counted in unchecked_targets_total.'),
|
|
163
210
|
results: z
|
|
164
|
-
.array(ResultSchema.describe('One result per
|
|
165
|
-
.describe('Per-feature verdicts and totals over the whole query, each with its own target rows for this page.'),
|
|
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.'),
|
|
166
217
|
all_clear: z
|
|
167
218
|
.boolean()
|
|
168
|
-
.describe('True only when every feature clears, which requires every target in the query to have been evaluated for it.'),
|
|
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.'),
|
|
169
220
|
}),
|
|
170
221
|
enrichment: {
|
|
171
222
|
data_version: DataVersionSchema.describe('Vintage of each bundled dataset behind this answer.'),
|
|
172
223
|
totalCount: z.number().describe('Number of targets the query resolved to, across every page.'),
|
|
173
224
|
shown: z.number().describe('Number of query targets this page covers.'),
|
|
174
|
-
cap: z
|
|
225
|
+
cap: z
|
|
226
|
+
.number()
|
|
227
|
+
.describe('The page size applied: target_limit, or 10 when target_limit was above 10.'),
|
|
175
228
|
truncated: z.boolean().describe('True when more query targets remain past this page.'),
|
|
176
229
|
nextOffset: z
|
|
177
230
|
.number()
|
|
@@ -204,8 +257,8 @@ export const browsercompatCompareSupport = tool('browsercompat_compare_support',
|
|
|
204
257
|
{
|
|
205
258
|
reason: 'invalid_target_query',
|
|
206
259
|
code: JsonRpcErrorCode.ValidationError,
|
|
207
|
-
when: 'browserslist rejected the targets query.',
|
|
208
|
-
recovery: '
|
|
260
|
+
when: 'browserslist rejected the targets query, or it requires config packages or custom configuration.',
|
|
261
|
+
recovery: 'Use a self-contained query without config packages or custom configuration — call browsercompat_list_reference with topic browserslist_agents for the 19 valid agent ids. A negation-only query needs a base, e.g. "defaults, not dead" rather than "not dead".',
|
|
209
262
|
thrownBy: 'service',
|
|
210
263
|
},
|
|
211
264
|
{
|
|
@@ -217,7 +270,7 @@ export const browsercompatCompareSupport = tool('browsercompat_compare_support',
|
|
|
217
270
|
{
|
|
218
271
|
reason: 'invalid_feature_input',
|
|
219
272
|
code: JsonRpcErrorCode.ValidationError,
|
|
220
|
-
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.',
|
|
221
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.',
|
|
222
275
|
},
|
|
223
276
|
],
|
|
@@ -251,7 +304,8 @@ export const browsercompatCompareSupport = tool('browsercompat_compare_support',
|
|
|
251
304
|
const queryTargets = tokens
|
|
252
305
|
.map((token) => byToken.get(token))
|
|
253
306
|
.filter((target) => target !== undefined);
|
|
254
|
-
const
|
|
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));
|
|
255
309
|
const isOnPage = (target) => onPage.has(tokenOf(target));
|
|
256
310
|
const usage = new Map();
|
|
257
311
|
/** A mapped target a comparison could not evaluate, reported the way an unmapped one is. */
|
|
@@ -269,11 +323,77 @@ export const browsercompatCompareSupport = tool('browsercompat_compare_support',
|
|
|
269
323
|
usage_percent: usagePercent,
|
|
270
324
|
};
|
|
271
325
|
};
|
|
272
|
-
/**
|
|
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
|
+
*/
|
|
273
392
|
const comparisons = new Map();
|
|
274
393
|
const results = [];
|
|
394
|
+
const omitted = input.features.slice(FEATURES_PER_CALL);
|
|
275
395
|
let comparableFeatures = 0;
|
|
276
|
-
for (const entry of input.features) {
|
|
396
|
+
for (const entry of input.features.slice(0, FEATURES_PER_CALL)) {
|
|
277
397
|
const query = entry.trim();
|
|
278
398
|
const resolution = await resolveFeature(query, {
|
|
279
399
|
resolve: input.resolve,
|
|
@@ -295,8 +415,35 @@ export const browsercompatCompareSupport = tool('browsercompat_compare_support',
|
|
|
295
415
|
const name = featureId === null ? undefined : baseline.feature(featureId)?.name;
|
|
296
416
|
const key = resolvedAs.bcd_key;
|
|
297
417
|
const leaf = key === null ? undefined : bcd.leaf(key);
|
|
298
|
-
|
|
299
|
-
|
|
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) {
|
|
300
447
|
results.push({
|
|
301
448
|
input: entry,
|
|
302
449
|
found: true,
|
|
@@ -304,47 +451,15 @@ export const browsercompatCompareSupport = tool('browsercompat_compare_support',
|
|
|
304
451
|
...(name === undefined ? {} : { name }),
|
|
305
452
|
verdict: 'ambiguous',
|
|
306
453
|
failing_targets: [],
|
|
307
|
-
|
|
308
|
-
guidance:
|
|
309
|
-
? `"${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.`
|
|
310
|
-
: `"${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.`,
|
|
311
456
|
});
|
|
312
457
|
continue;
|
|
313
458
|
}
|
|
314
|
-
let comparison = comparisons.get(
|
|
459
|
+
let comparison = comparisons.get(subject.cacheKey);
|
|
315
460
|
if (comparison === undefined) {
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
const evaluatedTokens = [];
|
|
319
|
-
for (const target of queryTargets) {
|
|
320
|
-
if ('reason' in target) {
|
|
321
|
-
notEvaluated.push(target);
|
|
322
|
-
continue;
|
|
323
|
-
}
|
|
324
|
-
const evaluation = bcd.supportAt(leaf, target.bcd_browser, target.bcd_release_index);
|
|
325
|
-
if (evaluation.verdict === 'unknown') {
|
|
326
|
-
notEvaluated.push(uncheckedRow(target, 'no_bcd_data'));
|
|
327
|
-
continue;
|
|
328
|
-
}
|
|
329
|
-
evaluatedTokens.push(tokenOf(target));
|
|
330
|
-
if (evaluation.verdict === 'supported')
|
|
331
|
-
continue;
|
|
332
|
-
failing.push({
|
|
333
|
-
agent: target.agent,
|
|
334
|
-
version_token: target.version_token,
|
|
335
|
-
bcd_browser: target.bcd_browser,
|
|
336
|
-
bcd_version: target.bcd_version,
|
|
337
|
-
verdict: evaluation.verdict,
|
|
338
|
-
});
|
|
339
|
-
}
|
|
340
|
-
comparison = {
|
|
341
|
-
failing,
|
|
342
|
-
unchecked: notEvaluated,
|
|
343
|
-
evaluatedTotal: evaluatedTokens.length,
|
|
344
|
-
evaluatedCoverage: targets.coverage(evaluatedTokens),
|
|
345
|
-
uncheckedCoverage: targets.coverage(notEvaluated.map(tokenOf)),
|
|
346
|
-
};
|
|
347
|
-
comparisons.set(key, comparison);
|
|
461
|
+
comparison = compare(subject.judge, subject.unknownReason);
|
|
462
|
+
comparisons.set(subject.cacheKey, comparison);
|
|
348
463
|
}
|
|
349
464
|
comparableFeatures += 1;
|
|
350
465
|
results.push({
|
|
@@ -352,6 +467,7 @@ export const browsercompatCompareSupport = tool('browsercompat_compare_support',
|
|
|
352
467
|
found: true,
|
|
353
468
|
resolved_as: resolvedAs,
|
|
354
469
|
...(name === undefined ? {} : { name }),
|
|
470
|
+
support_source: subject.source,
|
|
355
471
|
verdict: comparison.failing.length > 0
|
|
356
472
|
? 'fails'
|
|
357
473
|
: comparison.unchecked.length > 0
|
|
@@ -359,27 +475,39 @@ export const browsercompatCompareSupport = tool('browsercompat_compare_support',
|
|
|
359
475
|
: 'clears',
|
|
360
476
|
failing_targets: comparison.failing.filter(isOnPage),
|
|
361
477
|
failing_total: comparison.failing.length,
|
|
478
|
+
failing_ranges: comparison.ranges,
|
|
362
479
|
evaluated_total: comparison.evaluatedTotal,
|
|
363
480
|
evaluated_coverage_percent: comparison.evaluatedCoverage,
|
|
364
481
|
unchecked_total: comparison.unchecked.length,
|
|
365
482
|
unchecked_coverage_percent: comparison.uncheckedCoverage,
|
|
366
483
|
unchecked_targets: comparison.unchecked.filter(isOnPage),
|
|
484
|
+
...(subject.source === 'web_features_feature' ? batchCompatKeys(compatKeys) : {}),
|
|
367
485
|
});
|
|
368
486
|
}
|
|
369
487
|
/**
|
|
370
488
|
* A target is evaluated for the call only when every compared feature has
|
|
371
489
|
* data for it: the aggregate evaluated set is the intersection of the
|
|
372
|
-
* per-feature sets, and everything else in the query is unchecked.
|
|
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.
|
|
373
493
|
*/
|
|
374
|
-
const withoutData = new
|
|
375
|
-
|
|
376
|
-
|
|
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
|
+
}
|
|
377
504
|
const uncheckedTargets = queryTargets.flatMap((target) => {
|
|
378
505
|
if ('reason' in target)
|
|
379
506
|
return [target];
|
|
380
507
|
if (comparableFeatures === 0)
|
|
381
508
|
return [uncheckedRow(target, 'no_comparable_feature')];
|
|
382
|
-
|
|
509
|
+
const reason = withoutData.get(tokenOf(target));
|
|
510
|
+
return reason === undefined ? [] : [uncheckedRow(target, reason)];
|
|
383
511
|
});
|
|
384
512
|
const uncheckedTokens = new Set(uncheckedTargets.map(tokenOf));
|
|
385
513
|
const evaluatedTokens = tokens.filter((token) => !uncheckedTokens.has(token));
|
|
@@ -387,7 +515,7 @@ export const browsercompatCompareSupport = tool('browsercompat_compare_support',
|
|
|
387
515
|
const shown = onPage.size;
|
|
388
516
|
const nextOffset = input.target_offset + shown;
|
|
389
517
|
const truncated = nextOffset < tokens.length;
|
|
390
|
-
ctx.enrich({ totalCount: tokens.length, shown, cap:
|
|
518
|
+
ctx.enrich({ totalCount: tokens.length, shown, cap: pageSize, truncated });
|
|
391
519
|
if (truncated)
|
|
392
520
|
ctx.enrich({ nextOffset });
|
|
393
521
|
if (shown === 0) {
|
|
@@ -397,13 +525,13 @@ export const browsercompatCompareSupport = tool('browsercompat_compare_support',
|
|
|
397
525
|
}
|
|
398
526
|
if (comparableFeatures === 0) {
|
|
399
527
|
ctx.enrich({
|
|
400
|
-
uncheckedNotice: `No feature was comparable, so none of the ${tokens.length} target versions was evaluated (${uncheckedCoverage}% of
|
|
528
|
+
uncheckedNotice: `No feature was comparable, so none of the ${tokens.length} target versions was evaluated (${uncheckedCoverage}% of global traffic). Resolve the miss and ambiguous entries and call again.`,
|
|
401
529
|
});
|
|
402
530
|
}
|
|
403
531
|
else if (uncheckedTargets.length > 0) {
|
|
404
532
|
const agents = [...new Set(uncheckedTargets.map((target) => target.agent))].join(', ');
|
|
405
533
|
ctx.enrich({
|
|
406
|
-
uncheckedNotice: `${uncheckedTargets.length} of ${tokens.length} target versions were not evaluated for every compared feature (${agents}), together ${uncheckedCoverage}% of
|
|
534
|
+
uncheckedNotice: `${uncheckedTargets.length} of ${tokens.length} target versions were not evaluated for every compared feature (${agents}), together ${uncheckedCoverage}% of global traffic. No feature is reported as clearing them.`,
|
|
407
535
|
});
|
|
408
536
|
}
|
|
409
537
|
ctx.log.debug('Compared support', {
|
|
@@ -413,6 +541,7 @@ export const browsercompatCompareSupport = tool('browsercompat_compare_support',
|
|
|
413
541
|
evaluated: evaluatedTokens.length,
|
|
414
542
|
offset: input.target_offset,
|
|
415
543
|
shown,
|
|
544
|
+
omitted: omitted.length,
|
|
416
545
|
});
|
|
417
546
|
return {
|
|
418
547
|
query_echo: input.targets.trim(),
|
|
@@ -427,7 +556,8 @@ export const browsercompatCompareSupport = tool('browsercompat_compare_support',
|
|
|
427
556
|
target_coverage_percent: targets.coverage(evaluatedTokens),
|
|
428
557
|
unchecked_coverage_percent: uncheckedCoverage,
|
|
429
558
|
results,
|
|
430
|
-
|
|
559
|
+
...(omitted.length === 0 ? {} : { omitted_features: omitted }),
|
|
560
|
+
all_clear: omitted.length === 0 && results.every((result) => result.verdict === 'clears'),
|
|
431
561
|
};
|
|
432
562
|
},
|
|
433
563
|
format: (result) => {
|
|
@@ -438,9 +568,10 @@ export const browsercompatCompareSupport = tool('browsercompat_compare_support',
|
|
|
438
568
|
...(result.comparable_features === 0
|
|
439
569
|
? ['No feature was comparable, so no target version was evaluated.']
|
|
440
570
|
: []),
|
|
441
|
-
`Evaluated for every compared feature: ${result.evaluated_targets_total} of ${queryTotal} target versions (${result.target_coverage_percent}% of
|
|
571
|
+
`Evaluated for every compared feature: ${result.evaluated_targets_total} of ${queryTotal} target versions (${result.target_coverage_percent}% of global traffic) · not evaluated: ${result.unchecked_targets_total} (${result.unchecked_coverage_percent}%)`,
|
|
442
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`,
|
|
443
573
|
`**all_clear:** ${result.all_clear}`,
|
|
574
|
+
...(result.omitted_features ? [formatOmittedFeatures(result.omitted_features)] : []),
|
|
444
575
|
'',
|
|
445
576
|
];
|
|
446
577
|
for (const item of result.results) {
|
|
@@ -448,17 +579,27 @@ export const browsercompatCompareSupport = tool('browsercompat_compare_support',
|
|
|
448
579
|
if (item.resolved_as) {
|
|
449
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}`);
|
|
450
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
|
+
}
|
|
451
587
|
if (item.unchecked_targets) {
|
|
452
|
-
lines.push(` - evaluated on ${item.evaluated_total} of ${queryTotal} target versions (${item.evaluated_coverage_percent}% of
|
|
588
|
+
lines.push(` - evaluated on ${item.evaluated_total} of ${queryTotal} target versions (${item.evaluated_coverage_percent}% of global 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('; ')}`);
|
|
453
593
|
}
|
|
454
594
|
for (const target of item.failing_targets) {
|
|
455
|
-
|
|
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(' · ')}`}`);
|
|
456
597
|
}
|
|
457
598
|
for (const target of item.unchecked_targets ?? []) {
|
|
458
599
|
lines.push(` - not evaluated on ${markdownText(target.agent)} ${markdownText(target.version_token)} (${target.reason}, ${target.usage_percent}% usage)`);
|
|
459
600
|
}
|
|
460
601
|
if (item.compat_keys) {
|
|
461
|
-
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)}`);
|
|
462
603
|
}
|
|
463
604
|
if (item.guidance)
|
|
464
605
|
lines.push(` - ${markdownText(item.guidance)}`);
|