@cyanheads/browser-compat-mcp-server 0.1.5 → 0.2.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 +7 -6
- package/CLAUDE.md +7 -6
- package/Dockerfile +67 -50
- package/README.md +16 -10
- package/THIRD_PARTY_NOTICES.md +1 -1
- package/changelog/0.2.x/0.2.0.md +40 -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.map +1 -1
- package/dist/mcp-server/tools/definitions/browsercompat-check-baseline.tool.js +21 -16
- 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 +33 -2
- 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 +264 -89
- 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 +11 -0
- 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 +66 -21
- 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 +25 -18
- package/dist/mcp-server/tools/definitions/browsercompat-search-features.tool.js.map +1 -1
- package/dist/mcp-server/tools/definitions/compat-shapes.d.ts +1 -1
- package/dist/mcp-server/tools/definitions/compat-shapes.d.ts.map +1 -1
- package/dist/mcp-server/tools/definitions/compat-shapes.js +16 -13
- package/dist/mcp-server/tools/definitions/compat-shapes.js.map +1 -1
- package/dist/services/bcd/bcd-service.d.ts +4 -1
- package/dist/services/bcd/bcd-service.d.ts.map +1 -1
- package/dist/services/bcd/bcd-service.js +56 -14
- 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/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 +2 -6
- package/dist/services/search/search-service.d.ts.map +1 -1
- package/dist/services/search/search-service.js +3 -23
- 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 +7 -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 +9 -9
- package/server.json +3 -3
|
@@ -1,7 +1,9 @@
|
|
|
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 { z } from '@cyanheads/mcp-ts-core';
|
|
@@ -10,25 +12,33 @@ export declare const browsercompatCompareSupport: import("@cyanheads/mcp-ts-core
|
|
|
10
12
|
features: z.ZodArray<z.ZodString>;
|
|
11
13
|
targets: z.ZodString;
|
|
12
14
|
resolve: z.ZodDefault<z.ZodBoolean>;
|
|
15
|
+
target_offset: z.ZodDefault<z.ZodNumber>;
|
|
16
|
+
target_limit: z.ZodDefault<z.ZodNumber>;
|
|
13
17
|
}, z.core.$strip>, z.ZodObject<{
|
|
14
18
|
query_echo: z.ZodString;
|
|
19
|
+
comparable_features: z.ZodNumber;
|
|
15
20
|
targets_resolved: z.ZodArray<z.ZodObject<{
|
|
16
21
|
agent: z.ZodString;
|
|
17
22
|
version_token: z.ZodString;
|
|
18
23
|
bcd_browser: z.ZodString;
|
|
19
24
|
bcd_version: z.ZodNullable<z.ZodString>;
|
|
20
25
|
bcd_release_index: z.ZodNumber;
|
|
26
|
+
evaluated: z.ZodBoolean;
|
|
21
27
|
}, z.core.$strip>>;
|
|
28
|
+
targets_resolved_total: z.ZodNumber;
|
|
29
|
+
evaluated_targets_total: z.ZodNumber;
|
|
22
30
|
unchecked_targets: z.ZodArray<z.ZodObject<{
|
|
23
31
|
agent: z.ZodString;
|
|
24
32
|
version_token: z.ZodString;
|
|
25
33
|
reason: z.ZodEnum<{
|
|
26
34
|
no_bcd_browser: "no_bcd_browser";
|
|
27
35
|
no_bcd_data: "no_bcd_data";
|
|
36
|
+
no_comparable_feature: "no_comparable_feature";
|
|
28
37
|
unknown_version: "unknown_version";
|
|
29
38
|
}>;
|
|
30
39
|
usage_percent: z.ZodNumber;
|
|
31
40
|
}, z.core.$strip>>;
|
|
41
|
+
unchecked_targets_total: z.ZodNumber;
|
|
32
42
|
target_coverage_percent: z.ZodNumber;
|
|
33
43
|
unchecked_coverage_percent: z.ZodNumber;
|
|
34
44
|
results: z.ZodArray<z.ZodObject<{
|
|
@@ -68,6 +78,22 @@ export declare const browsercompatCompareSupport: import("@cyanheads/mcp-ts-core
|
|
|
68
78
|
unsupported: "unsupported";
|
|
69
79
|
}>;
|
|
70
80
|
}, z.core.$strip>>;
|
|
81
|
+
failing_total: z.ZodOptional<z.ZodNumber>;
|
|
82
|
+
evaluated_total: z.ZodOptional<z.ZodNumber>;
|
|
83
|
+
evaluated_coverage_percent: z.ZodOptional<z.ZodNumber>;
|
|
84
|
+
unchecked_total: z.ZodOptional<z.ZodNumber>;
|
|
85
|
+
unchecked_coverage_percent: z.ZodOptional<z.ZodNumber>;
|
|
86
|
+
unchecked_targets: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
87
|
+
agent: z.ZodString;
|
|
88
|
+
version_token: z.ZodString;
|
|
89
|
+
reason: z.ZodEnum<{
|
|
90
|
+
no_bcd_browser: "no_bcd_browser";
|
|
91
|
+
no_bcd_data: "no_bcd_data";
|
|
92
|
+
no_comparable_feature: "no_comparable_feature";
|
|
93
|
+
unknown_version: "unknown_version";
|
|
94
|
+
}>;
|
|
95
|
+
usage_percent: z.ZodNumber;
|
|
96
|
+
}, z.core.$strip>>>;
|
|
71
97
|
compat_keys: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
72
98
|
guidance: z.ZodOptional<z.ZodString>;
|
|
73
99
|
}, z.core.$strip>>;
|
|
@@ -97,7 +123,12 @@ export declare const browsercompatCompareSupport: import("@cyanheads/mcp-ts-core
|
|
|
97
123
|
browserslist: z.ZodString;
|
|
98
124
|
}, z.core.$strip>;
|
|
99
125
|
readonly totalCount: z.ZodNumber;
|
|
126
|
+
readonly shown: z.ZodNumber;
|
|
127
|
+
readonly cap: z.ZodNumber;
|
|
128
|
+
readonly truncated: z.ZodBoolean;
|
|
129
|
+
readonly nextOffset: z.ZodOptional<z.ZodNumber>;
|
|
100
130
|
readonly attribution: z.ZodString;
|
|
101
131
|
readonly uncheckedNotice: z.ZodOptional<z.ZodString>;
|
|
132
|
+
readonly offsetNotice: z.ZodOptional<z.ZodString>;
|
|
102
133
|
}>;
|
|
103
134
|
//# sourceMappingURL=browsercompat-compare-support.tool.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"browsercompat-compare-support.tool.d.ts","sourceRoot":"","sources":["../../../../src/mcp-server/tools/definitions/browsercompat-compare-support.tool.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"browsercompat-compare-support.tool.d.ts","sourceRoot":"","sources":["../../../../src/mcp-server/tools/definitions/browsercompat-compare-support.tool.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAQ,CAAC,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AA0IjE,eAAO,MAAM,2BAA2B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA6etC,CAAC"}
|
|
@@ -1,16 +1,20 @@
|
|
|
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';
|
|
17
|
+
import { markdownText } from '../../../utils/markdown-text.js';
|
|
14
18
|
import { ResolvedAsSchema } from './compat-shapes.js';
|
|
15
19
|
const FailingTargetSchema = z.object({
|
|
16
20
|
agent: z.string().describe('browserslist agent id the target came from.'),
|
|
@@ -36,13 +40,16 @@ const ResolvedTargetSchema = z.object({
|
|
|
36
40
|
.number()
|
|
37
41
|
.int()
|
|
38
42
|
.describe('Release ordinal used for comparison; -1 when the token predates every release.'),
|
|
43
|
+
evaluated: z
|
|
44
|
+
.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.'),
|
|
39
46
|
});
|
|
40
47
|
const UncheckedTargetSchema = z.object({
|
|
41
48
|
agent: z.string().describe('browserslist agent id.'),
|
|
42
49
|
version_token: z.string().describe('Version token browserslist produced for that agent.'),
|
|
43
50
|
reason: z
|
|
44
|
-
.enum(['no_bcd_browser', 'unknown_version', 'no_bcd_data'])
|
|
45
|
-
.describe('no_bcd_browser when the agent has no counterpart, unknown_version when the token maps to no release, no_bcd_data when a feature records nothing for that browser.'),
|
|
51
|
+
.enum(['no_bcd_browser', 'unknown_version', 'no_bcd_data', 'no_comparable_feature'])
|
|
52
|
+
.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 feature records nothing for that browser, no_comparable_feature when every entry in features was a miss or ambiguous so nothing was compared.'),
|
|
46
53
|
usage_percent: z.number().describe('Share of tracked global traffic this target covers.'),
|
|
47
54
|
});
|
|
48
55
|
const ResultSchema = z.object({
|
|
@@ -52,18 +59,47 @@ const ResultSchema = z.object({
|
|
|
52
59
|
name: z.string().optional().describe('web-features display name for the feature.'),
|
|
53
60
|
verdict: z
|
|
54
61
|
.enum(['clears', 'fails', 'inconclusive', 'miss', 'ambiguous'])
|
|
55
|
-
.describe('
|
|
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 spans more than one compat key or owns none.'),
|
|
56
63
|
failing_targets: z
|
|
57
64
|
.array(FailingTargetSchema.describe('A target this feature does not clear.'))
|
|
58
|
-
.describe('
|
|
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.'),
|
|
66
|
+
failing_total: z
|
|
67
|
+
.number()
|
|
68
|
+
.int()
|
|
69
|
+
.optional()
|
|
70
|
+
.describe('Failing targets across the whole query. Present when the feature was compared, as are the five fields after it.'),
|
|
71
|
+
evaluated_total: z
|
|
72
|
+
.number()
|
|
73
|
+
.int()
|
|
74
|
+
.optional()
|
|
75
|
+
.describe('Query targets this feature has compatibility data for, across the whole query.'),
|
|
76
|
+
evaluated_coverage_percent: z
|
|
77
|
+
.number()
|
|
78
|
+
.optional()
|
|
79
|
+
.describe('Share of tracked global traffic the targets evaluated for this feature cover.'),
|
|
80
|
+
unchecked_total: z
|
|
81
|
+
.number()
|
|
82
|
+
.int()
|
|
83
|
+
.optional()
|
|
84
|
+
.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.'),
|
|
85
|
+
unchecked_coverage_percent: z
|
|
86
|
+
.number()
|
|
87
|
+
.optional()
|
|
88
|
+
.describe('Share of tracked global traffic the targets not evaluated for this feature cover.'),
|
|
89
|
+
unchecked_targets: z
|
|
90
|
+
.array(UncheckedTargetSchema.describe('A target this feature was not evaluated against.'))
|
|
91
|
+
.optional()
|
|
92
|
+
.describe('The targets not evaluated for this feature among the query targets on this page, each with its reason.'),
|
|
59
93
|
compat_keys: z
|
|
60
94
|
.array(z.string())
|
|
61
95
|
.optional()
|
|
62
96
|
.describe('Present on an ambiguous verdict — the browser-compat-data keys the feature owns. Re-run with one of them.'),
|
|
63
97
|
guidance: z.string().optional().describe('What to do next on a miss or an ambiguous verdict.'),
|
|
64
98
|
});
|
|
99
|
+
/** The browserslist token a target row came from. */
|
|
100
|
+
const tokenOf = (target) => `${target.agent} ${target.version_token}`.trim();
|
|
65
101
|
export const browsercompatCompareSupport = tool('browsercompat_compare_support', {
|
|
66
|
-
description: 'Compute whether a set of web features clears an explicit browserslist target query.
|
|
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 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 — 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.',
|
|
67
103
|
annotations: { readOnlyHint: true, idempotentHint: true, openWorldHint: false },
|
|
68
104
|
input: z.object({
|
|
69
105
|
features: z
|
|
@@ -79,44 +115,90 @@ export const browsercompatCompareSupport = tool('browsercompat_compare_support',
|
|
|
79
115
|
resolve: z
|
|
80
116
|
.boolean()
|
|
81
117
|
.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 gets a verdict, several keys of one web-features feature resolve to the feature as verdict ambiguous 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.'),
|
|
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 gets a verdict, several keys of one web-features feature resolve to the feature as verdict ambiguous 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
|
+
target_offset: z
|
|
120
|
+
.number()
|
|
121
|
+
.int()
|
|
122
|
+
.min(0)
|
|
123
|
+
.default(0)
|
|
124
|
+
.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.'),
|
|
125
|
+
target_limit: z
|
|
126
|
+
.number()
|
|
127
|
+
.int()
|
|
128
|
+
.min(1)
|
|
129
|
+
.max(10)
|
|
130
|
+
.default(10)
|
|
131
|
+
.describe('How many query targets this page covers, 1 to 10. It bounds every list of target rows in the response and never the evaluation: verdicts, coverage, and totals always describe the whole query.'),
|
|
83
132
|
}),
|
|
84
133
|
output: z.object({
|
|
85
134
|
query_echo: z.string().describe('The targets query as the server parsed it.'),
|
|
135
|
+
comparable_features: z
|
|
136
|
+
.number()
|
|
137
|
+
.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.'),
|
|
86
139
|
targets_resolved: z
|
|
87
140
|
.array(ResolvedTargetSchema.describe('A target that mapped onto a concrete release.'))
|
|
88
|
-
.describe('
|
|
141
|
+
.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.'),
|
|
142
|
+
targets_resolved_total: z
|
|
143
|
+
.number()
|
|
144
|
+
.int()
|
|
145
|
+
.describe('Query targets that map onto a browser-compat-data release, across every page.'),
|
|
146
|
+
evaluated_targets_total: z
|
|
147
|
+
.number()
|
|
148
|
+
.int()
|
|
149
|
+
.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
150
|
unchecked_targets: z
|
|
90
151
|
.array(UncheckedTargetSchema.describe('A target that was not evaluated.'))
|
|
91
|
-
.describe('
|
|
152
|
+
.describe('The query targets on this page that were not evaluated for every compared feature, each with the reason.'),
|
|
153
|
+
unchecked_targets_total: z
|
|
154
|
+
.number()
|
|
155
|
+
.int()
|
|
156
|
+
.describe('Query targets not evaluated for every compared feature, across every page.'),
|
|
92
157
|
target_coverage_percent: z
|
|
93
158
|
.number()
|
|
94
|
-
.describe('Share of tracked global traffic the evaluated
|
|
159
|
+
.describe('Share of tracked global traffic covered by the targets evaluated for every compared feature; 0 when no feature was comparable.'),
|
|
95
160
|
unchecked_coverage_percent: z
|
|
96
161
|
.number()
|
|
97
|
-
.describe('Share of tracked global traffic the
|
|
162
|
+
.describe('Share of tracked global traffic covered by the targets counted in unchecked_targets_total.'),
|
|
98
163
|
results: z
|
|
99
164
|
.array(ResultSchema.describe('One result per input entry, in input order.'))
|
|
100
|
-
.describe('Per-feature verdicts
|
|
165
|
+
.describe('Per-feature verdicts and totals over the whole query, each with its own target rows for this page.'),
|
|
101
166
|
all_clear: z
|
|
102
167
|
.boolean()
|
|
103
|
-
.describe('True only when every feature clears
|
|
168
|
+
.describe('True only when every feature clears, which requires every target in the query to have been evaluated for it.'),
|
|
104
169
|
}),
|
|
105
170
|
enrichment: {
|
|
106
171
|
data_version: DataVersionSchema.describe('Vintage of each bundled dataset behind this answer.'),
|
|
107
|
-
totalCount: z.number().describe('Number of
|
|
172
|
+
totalCount: z.number().describe('Number of targets the query resolved to, across every page.'),
|
|
173
|
+
shown: z.number().describe('Number of query targets this page covers.'),
|
|
174
|
+
cap: z.number().describe('The target_limit that was applied.'),
|
|
175
|
+
truncated: z.boolean().describe('True when more query targets remain past this page.'),
|
|
176
|
+
nextOffset: z
|
|
177
|
+
.number()
|
|
178
|
+
.optional()
|
|
179
|
+
.describe('The target_offset of the next page. Present only while targets remain past this page.'),
|
|
108
180
|
attribution: z
|
|
109
181
|
.string()
|
|
110
182
|
.describe('Required attribution for the caniuse-derived coverage figures in this response.'),
|
|
111
183
|
uncheckedNotice: z
|
|
112
184
|
.string()
|
|
113
185
|
.optional()
|
|
114
|
-
.describe('
|
|
186
|
+
.describe('How many of the query targets were not evaluated for every compared feature, the agents they belong to, and their combined usage share.'),
|
|
187
|
+
offsetNotice: z
|
|
188
|
+
.string()
|
|
189
|
+
.optional()
|
|
190
|
+
.describe('Why this page carries no target rows, and the offsets that do.'),
|
|
115
191
|
},
|
|
116
192
|
enrichmentTrailer: {
|
|
117
193
|
data_version: { render: renderDataVersion },
|
|
118
|
-
|
|
119
|
-
|
|
194
|
+
totalCount: { render: (value) => `**Targets in query:** ${value}` },
|
|
195
|
+
shown: { render: (value) => `**Targets on this page:** ${value}` },
|
|
196
|
+
cap: { render: (value) => `**Page size (target_limit):** ${value}` },
|
|
197
|
+
truncated: { render: (value) => `**More targets remain:** ${value ? 'yes' : 'no'}` },
|
|
198
|
+
nextOffset: { render: (value) => `**Next page:** call again with target_offset ${value}` },
|
|
199
|
+
attribution: { render: (value) => `**Usage data:** ${markdownText(value)}` },
|
|
200
|
+
uncheckedNotice: { render: (value) => `**Not evaluated:** ${markdownText(value ?? '')}` },
|
|
201
|
+
offsetNotice: { render: (value) => `**Empty page:** ${value}` },
|
|
120
202
|
},
|
|
121
203
|
errors: [
|
|
122
204
|
{
|
|
@@ -150,25 +232,47 @@ export const browsercompatCompareSupport = tool('browsercompat_compare_support',
|
|
|
150
232
|
getBaselineService(),
|
|
151
233
|
getTargetsService(),
|
|
152
234
|
]);
|
|
153
|
-
const tokens = targets.queryTokens(input.targets
|
|
154
|
-
const { resolved, unchecked } = await targets.resolveTargets(tokens);
|
|
235
|
+
const tokens = targets.queryTokens(input.targets);
|
|
236
|
+
const { resolved, unchecked: unmapped } = await targets.resolveTargets(tokens);
|
|
155
237
|
/**
|
|
156
238
|
* Only a query with nothing left to evaluate is an error. A mapped agent
|
|
157
239
|
* whose version token does not resolve carries a per-token reason of its
|
|
158
240
|
* own, so it stays an ordinary response with the token in unchecked_targets
|
|
159
241
|
* — the same treatment it gets alongside a token that did resolve.
|
|
160
242
|
*/
|
|
161
|
-
if (resolved.length === 0 && !
|
|
162
|
-
const
|
|
163
|
-
throw ctx.fail('no_targets_resolved',
|
|
243
|
+
if (resolved.length === 0 && !unmapped.some((target) => target.reason === 'unknown_version')) {
|
|
244
|
+
const agents = [...new Set(unmapped.map((target) => target.agent))].join(', ');
|
|
245
|
+
throw ctx.fail('no_targets_resolved', unmapped.length === 0
|
|
164
246
|
? `"${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);
|
|
247
|
+
: `"${input.targets}" resolved only to agents with no browser-compat-data counterpart: ${agents}.`);
|
|
170
248
|
}
|
|
249
|
+
/** Every query target in browserslist order, whether or not it mapped onto a release. */
|
|
250
|
+
const byToken = new Map([...resolved, ...unmapped].map((target) => [tokenOf(target), target]));
|
|
251
|
+
const queryTargets = tokens
|
|
252
|
+
.map((token) => byToken.get(token))
|
|
253
|
+
.filter((target) => target !== undefined);
|
|
254
|
+
const onPage = new Set(tokens.slice(input.target_offset, input.target_offset + input.target_limit));
|
|
255
|
+
const isOnPage = (target) => onPage.has(tokenOf(target));
|
|
256
|
+
const usage = new Map();
|
|
257
|
+
/** A mapped target a comparison could not evaluate, reported the way an unmapped one is. */
|
|
258
|
+
const uncheckedRow = (target, reason) => {
|
|
259
|
+
const token = tokenOf(target);
|
|
260
|
+
let usagePercent = usage.get(token);
|
|
261
|
+
if (usagePercent === undefined) {
|
|
262
|
+
usagePercent = targets.coverage([token]);
|
|
263
|
+
usage.set(token, usagePercent);
|
|
264
|
+
}
|
|
265
|
+
return {
|
|
266
|
+
agent: target.agent,
|
|
267
|
+
version_token: target.version_token,
|
|
268
|
+
reason,
|
|
269
|
+
usage_percent: usagePercent,
|
|
270
|
+
};
|
|
271
|
+
};
|
|
272
|
+
/** Keyed by compat key, so a repeated entry is evaluated once. */
|
|
273
|
+
const comparisons = new Map();
|
|
171
274
|
const results = [];
|
|
275
|
+
let comparableFeatures = 0;
|
|
172
276
|
for (const entry of input.features) {
|
|
173
277
|
const query = entry.trim();
|
|
174
278
|
const resolution = await resolveFeature(query, {
|
|
@@ -191,7 +295,7 @@ export const browsercompatCompareSupport = tool('browsercompat_compare_support',
|
|
|
191
295
|
const name = featureId === null ? undefined : baseline.feature(featureId)?.name;
|
|
192
296
|
const key = resolvedAs.bcd_key;
|
|
193
297
|
const leaf = key === null ? undefined : bcd.leaf(key);
|
|
194
|
-
if (leaf === undefined) {
|
|
298
|
+
if (key === null || leaf === undefined) {
|
|
195
299
|
const compatKeys = resolution.compat_keys ?? [];
|
|
196
300
|
results.push({
|
|
197
301
|
input: entry,
|
|
@@ -207,111 +311,182 @@ export const browsercompatCompareSupport = tool('browsercompat_compare_support',
|
|
|
207
311
|
});
|
|
208
312
|
continue;
|
|
209
313
|
}
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
const
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
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
|
-
});
|
|
314
|
+
let comparison = comparisons.get(key);
|
|
315
|
+
if (comparison === undefined) {
|
|
316
|
+
const failing = [];
|
|
317
|
+
const notEvaluated = [];
|
|
318
|
+
const evaluatedTokens = [];
|
|
319
|
+
for (const target of queryTargets) {
|
|
320
|
+
if ('reason' in target) {
|
|
321
|
+
notEvaluated.push(target);
|
|
322
|
+
continue;
|
|
227
323
|
}
|
|
228
|
-
|
|
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
|
+
});
|
|
229
339
|
}
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
}
|
|
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);
|
|
237
348
|
}
|
|
349
|
+
comparableFeatures += 1;
|
|
238
350
|
results.push({
|
|
239
351
|
input: entry,
|
|
240
352
|
found: true,
|
|
241
353
|
resolved_as: resolvedAs,
|
|
242
354
|
...(name === undefined ? {} : { name }),
|
|
243
|
-
verdict: failing.length > 0
|
|
244
|
-
|
|
355
|
+
verdict: comparison.failing.length > 0
|
|
356
|
+
? 'fails'
|
|
357
|
+
: comparison.unchecked.length > 0
|
|
358
|
+
? 'inconclusive'
|
|
359
|
+
: 'clears',
|
|
360
|
+
failing_targets: comparison.failing.filter(isOnPage),
|
|
361
|
+
failing_total: comparison.failing.length,
|
|
362
|
+
evaluated_total: comparison.evaluatedTotal,
|
|
363
|
+
evaluated_coverage_percent: comparison.evaluatedCoverage,
|
|
364
|
+
unchecked_total: comparison.unchecked.length,
|
|
365
|
+
unchecked_coverage_percent: comparison.uncheckedCoverage,
|
|
366
|
+
unchecked_targets: comparison.unchecked.filter(isOnPage),
|
|
245
367
|
});
|
|
246
368
|
}
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
369
|
+
/**
|
|
370
|
+
* A target is evaluated for the call only when every compared feature has
|
|
371
|
+
* data for it: the aggregate evaluated set is the intersection of the
|
|
372
|
+
* per-feature sets, and everything else in the query is unchecked.
|
|
373
|
+
*/
|
|
374
|
+
const withoutData = new Set([...comparisons.values()].flatMap((comparison) => comparison.unchecked
|
|
375
|
+
.filter((target) => target.reason === 'no_bcd_data')
|
|
376
|
+
.map((target) => tokenOf(target))));
|
|
377
|
+
const uncheckedTargets = queryTargets.flatMap((target) => {
|
|
378
|
+
if ('reason' in target)
|
|
379
|
+
return [target];
|
|
380
|
+
if (comparableFeatures === 0)
|
|
381
|
+
return [uncheckedRow(target, 'no_comparable_feature')];
|
|
382
|
+
return withoutData.has(tokenOf(target)) ? [uncheckedRow(target, 'no_bcd_data')] : [];
|
|
383
|
+
});
|
|
384
|
+
const uncheckedTokens = new Set(uncheckedTargets.map(tokenOf));
|
|
385
|
+
const evaluatedTokens = tokens.filter((token) => !uncheckedTokens.has(token));
|
|
386
|
+
const uncheckedCoverage = targets.coverage([...uncheckedTokens]);
|
|
387
|
+
const shown = onPage.size;
|
|
388
|
+
const nextOffset = input.target_offset + shown;
|
|
389
|
+
const truncated = nextOffset < tokens.length;
|
|
390
|
+
ctx.enrich({ totalCount: tokens.length, shown, cap: input.target_limit, truncated });
|
|
391
|
+
if (truncated)
|
|
392
|
+
ctx.enrich({ nextOffset });
|
|
393
|
+
if (shown === 0) {
|
|
394
|
+
ctx.enrich({
|
|
395
|
+
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.`,
|
|
396
|
+
});
|
|
397
|
+
}
|
|
398
|
+
if (comparableFeatures === 0) {
|
|
255
399
|
ctx.enrich({
|
|
256
|
-
uncheckedNotice:
|
|
400
|
+
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.`,
|
|
401
|
+
});
|
|
402
|
+
}
|
|
403
|
+
else if (uncheckedTargets.length > 0) {
|
|
404
|
+
const agents = [...new Set(uncheckedTargets.map((target) => target.agent))].join(', ');
|
|
405
|
+
ctx.enrich({
|
|
406
|
+
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
407
|
});
|
|
258
408
|
}
|
|
259
409
|
ctx.log.debug('Compared support', {
|
|
260
410
|
targets: input.targets,
|
|
261
|
-
|
|
262
|
-
|
|
411
|
+
queryTargets: tokens.length,
|
|
412
|
+
mapped: resolved.length,
|
|
413
|
+
evaluated: evaluatedTokens.length,
|
|
414
|
+
offset: input.target_offset,
|
|
415
|
+
shown,
|
|
263
416
|
});
|
|
264
417
|
return {
|
|
265
418
|
query_echo: input.targets.trim(),
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
419
|
+
comparable_features: comparableFeatures,
|
|
420
|
+
targets_resolved: resolved
|
|
421
|
+
.filter(isOnPage)
|
|
422
|
+
.map((target) => ({ ...target, evaluated: !uncheckedTokens.has(tokenOf(target)) })),
|
|
423
|
+
targets_resolved_total: resolved.length,
|
|
424
|
+
evaluated_targets_total: evaluatedTokens.length,
|
|
425
|
+
unchecked_targets: uncheckedTargets.filter(isOnPage),
|
|
426
|
+
unchecked_targets_total: uncheckedTargets.length,
|
|
427
|
+
target_coverage_percent: targets.coverage(evaluatedTokens),
|
|
428
|
+
unchecked_coverage_percent: uncheckedCoverage,
|
|
270
429
|
results,
|
|
271
|
-
all_clear:
|
|
430
|
+
all_clear: results.every((result) => result.verdict === 'clears'),
|
|
272
431
|
};
|
|
273
432
|
},
|
|
274
433
|
format: (result) => {
|
|
275
434
|
const clearing = result.results.filter((item) => item.verdict === 'clears').length;
|
|
435
|
+
const queryTotal = result.evaluated_targets_total + result.unchecked_targets_total;
|
|
276
436
|
const lines = [
|
|
277
|
-
`# ${clearing} of ${result.results.length} features clears
|
|
278
|
-
|
|
279
|
-
|
|
437
|
+
`# ${clearing} of ${result.results.length} features clears ${markdown().inlineCode(result.query_echo).build()}`,
|
|
438
|
+
...(result.comparable_features === 0
|
|
439
|
+
? ['No feature was comparable, so no target version was evaluated.']
|
|
440
|
+
: []),
|
|
441
|
+
`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}%)`,
|
|
442
|
+
`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
443
|
`**all_clear:** ${result.all_clear}`,
|
|
281
444
|
'',
|
|
282
445
|
];
|
|
283
446
|
for (const item of result.results) {
|
|
284
|
-
lines.push(`**${item.verdict}** ${item.name ?? item.input} (input ${item.input}, found ${item.found})`);
|
|
447
|
+
lines.push(`**${item.verdict}** ${markdownText(item.name ?? item.input)} (input ${markdownText(item.input)}, found ${item.found})`);
|
|
285
448
|
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}`);
|
|
449
|
+
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
|
+
}
|
|
451
|
+
if (item.unchecked_targets) {
|
|
452
|
+
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`);
|
|
287
453
|
}
|
|
288
454
|
for (const target of item.failing_targets) {
|
|
289
|
-
lines.push(` - fails on ${target.agent} ${target.version_token} → ${target.bcd_browser} ${target.bcd_version ?? 'older than all releases'} (${target.verdict})`);
|
|
455
|
+
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})`);
|
|
456
|
+
}
|
|
457
|
+
for (const target of item.unchecked_targets ?? []) {
|
|
458
|
+
lines.push(` - not evaluated on ${markdownText(target.agent)} ${markdownText(target.version_token)} (${target.reason}, ${target.usage_percent}% usage)`);
|
|
290
459
|
}
|
|
291
460
|
if (item.compat_keys) {
|
|
292
|
-
lines.push(` - compat_keys: ${item.compat_keys.length === 0 ? 'none — this entry owns no browser-compat-data keys' : item.compat_keys.join(', ')}`);
|
|
461
|
+
lines.push(` - compat_keys: ${item.compat_keys.length === 0 ? 'none — this entry owns no browser-compat-data keys' : item.compat_keys.map(markdownText).join(', ')}`);
|
|
293
462
|
}
|
|
294
463
|
if (item.guidance)
|
|
295
|
-
lines.push(` - ${item.guidance}`);
|
|
464
|
+
lines.push(` - ${markdownText(item.guidance)}`);
|
|
296
465
|
}
|
|
297
|
-
lines.push('',
|
|
298
|
-
if (result.
|
|
299
|
-
lines.push('No target version
|
|
466
|
+
lines.push('', `## Targets mapped to a release — ${result.targets_resolved.length} of ${result.targets_resolved_total} on this page`);
|
|
467
|
+
if (result.targets_resolved_total === 0) {
|
|
468
|
+
lines.push('No target version maps to a browser-compat-data release.');
|
|
469
|
+
}
|
|
470
|
+
else if (result.targets_resolved.length === 0) {
|
|
471
|
+
lines.push(`None of the ${result.targets_resolved_total} mapped target versions is on this page.`);
|
|
300
472
|
}
|
|
301
473
|
else {
|
|
302
|
-
lines.push('| Target | browser-compat-data |', '
|
|
474
|
+
lines.push('| Target | browser-compat-data | Evaluated for every compared feature |', '|:--|:--|:--|');
|
|
303
475
|
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}) |`);
|
|
476
|
+
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
477
|
}
|
|
306
478
|
}
|
|
307
|
-
lines.push('',
|
|
308
|
-
if (result.
|
|
309
|
-
lines.push('Every
|
|
479
|
+
lines.push('', `## Not evaluated for every compared feature — ${result.unchecked_targets.length} of ${result.unchecked_targets_total} on this page`);
|
|
480
|
+
if (result.unchecked_targets_total === 0) {
|
|
481
|
+
lines.push('Every target version was evaluated for every compared feature.');
|
|
482
|
+
}
|
|
483
|
+
else if (result.unchecked_targets.length === 0) {
|
|
484
|
+
lines.push(`None of the ${result.unchecked_targets_total} unevaluated target versions is on this page.`);
|
|
310
485
|
}
|
|
311
486
|
else {
|
|
312
487
|
lines.push('| Target | Reason | Usage |', '|:--|:--|:--|');
|
|
313
488
|
for (const target of result.unchecked_targets) {
|
|
314
|
-
lines.push(`| ${target.agent} ${target.version_token} | ${target.reason} | ${target.usage_percent}% |`);
|
|
489
|
+
lines.push(`| ${markdownText(target.agent)} ${markdownText(target.version_token)} | ${target.reason} | ${target.usage_percent}% |`);
|
|
315
490
|
}
|
|
316
491
|
}
|
|
317
492
|
return [{ type: 'text', text: lines.join('\n') }];
|