@cyanheads/browser-compat-mcp-server 0.2.0 → 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.
Files changed (47) hide show
  1. package/AGENTS.md +5 -5
  2. package/CLAUDE.md +5 -5
  3. package/Dockerfile +16 -7
  4. package/README.md +25 -19
  5. package/THIRD_PARTY_NOTICES.md +4 -4
  6. package/changelog/0.2.x/0.2.1.md +41 -0
  7. package/dist/index.js +1 -1
  8. package/dist/index.js.map +1 -1
  9. package/dist/mcp-server/tools/definitions/browsercompat-check-baseline.tool.d.ts +4 -1
  10. package/dist/mcp-server/tools/definitions/browsercompat-check-baseline.tool.d.ts.map +1 -1
  11. package/dist/mcp-server/tools/definitions/browsercompat-check-baseline.tool.js +44 -17
  12. package/dist/mcp-server/tools/definitions/browsercompat-check-baseline.tool.js.map +1 -1
  13. package/dist/mcp-server/tools/definitions/browsercompat-compare-support.tool.d.ts +42 -1
  14. package/dist/mcp-server/tools/definitions/browsercompat-compare-support.tool.d.ts.map +1 -1
  15. package/dist/mcp-server/tools/definitions/browsercompat-compare-support.tool.js +216 -75
  16. package/dist/mcp-server/tools/definitions/browsercompat-compare-support.tool.js.map +1 -1
  17. package/dist/mcp-server/tools/definitions/browsercompat-get-feature.tool.d.ts +44 -13
  18. package/dist/mcp-server/tools/definitions/browsercompat-get-feature.tool.d.ts.map +1 -1
  19. package/dist/mcp-server/tools/definitions/browsercompat-get-feature.tool.js +67 -15
  20. package/dist/mcp-server/tools/definitions/browsercompat-get-feature.tool.js.map +1 -1
  21. package/dist/mcp-server/tools/definitions/browsercompat-search-features.tool.d.ts.map +1 -1
  22. package/dist/mcp-server/tools/definitions/browsercompat-search-features.tool.js +13 -5
  23. package/dist/mcp-server/tools/definitions/browsercompat-search-features.tool.js.map +1 -1
  24. package/dist/mcp-server/tools/definitions/compat-shapes.d.ts +128 -16
  25. package/dist/mcp-server/tools/definitions/compat-shapes.d.ts.map +1 -1
  26. package/dist/mcp-server/tools/definitions/compat-shapes.js +178 -22
  27. package/dist/mcp-server/tools/definitions/compat-shapes.js.map +1 -1
  28. package/dist/services/baseline/baseline-service.d.ts +11 -3
  29. package/dist/services/baseline/baseline-service.d.ts.map +1 -1
  30. package/dist/services/baseline/baseline-service.js +29 -2
  31. package/dist/services/baseline/baseline-service.js.map +1 -1
  32. package/dist/services/baseline/types.d.ts +11 -0
  33. package/dist/services/baseline/types.d.ts.map +1 -1
  34. package/dist/services/bcd/bcd-service.d.ts +29 -11
  35. package/dist/services/bcd/bcd-service.d.ts.map +1 -1
  36. package/dist/services/bcd/bcd-service.js +145 -73
  37. package/dist/services/bcd/bcd-service.js.map +1 -1
  38. package/dist/services/bcd/types.d.ts +29 -4
  39. package/dist/services/bcd/types.d.ts.map +1 -1
  40. package/dist/services/search/search-service.d.ts +20 -2
  41. package/dist/services/search/search-service.d.ts.map +1 -1
  42. package/dist/services/search/search-service.js +115 -20
  43. package/dist/services/search/search-service.js.map +1 -1
  44. package/dist/services/targets/types.d.ts +6 -4
  45. package/dist/services/targets/types.d.ts.map +1 -1
  46. package/package.json +15 -15
  47. package/server.json +10 -24
@@ -34,6 +34,7 @@ export declare const browsercompatCompareSupport: import("@cyanheads/mcp-ts-core
34
34
  no_bcd_browser: "no_bcd_browser";
35
35
  no_bcd_data: "no_bcd_data";
36
36
  no_comparable_feature: "no_comparable_feature";
37
+ no_feature_level_data: "no_feature_level_data";
37
38
  unknown_version: "unknown_version";
38
39
  }>;
39
40
  usage_percent: z.ZodNumber;
@@ -64,13 +65,34 @@ export declare const browsercompatCompareSupport: import("@cyanheads/mcp-ts-core
64
65
  inconclusive: "inconclusive";
65
66
  miss: "miss";
66
67
  }>;
68
+ support_source: z.ZodOptional<z.ZodEnum<{
69
+ bcd_key: "bcd_key";
70
+ web_features_feature: "web_features_feature";
71
+ }>>;
67
72
  failing_targets: z.ZodArray<z.ZodObject<{
73
+ version_added: z.ZodOptional<z.ZodString>;
74
+ version_added_is_upper_bound: z.ZodOptional<z.ZodBoolean>;
75
+ version_removed: z.ZodOptional<z.ZodString>;
76
+ version_last: z.ZodOptional<z.ZodString>;
77
+ partial: z.ZodOptional<z.ZodBoolean>;
78
+ prefix: z.ZodOptional<z.ZodString>;
79
+ alternative_name: z.ZodOptional<z.ZodString>;
80
+ flags: z.ZodOptional<z.ZodArray<z.ZodObject<{
81
+ name: z.ZodString;
82
+ type: z.ZodEnum<{
83
+ preference: "preference";
84
+ runtime_flag: "runtime_flag";
85
+ }>;
86
+ value_to_set: z.ZodOptional<z.ZodString>;
87
+ }, z.core.$strip>>>;
68
88
  agent: z.ZodString;
69
89
  version_token: z.ZodString;
70
90
  bcd_browser: z.ZodString;
71
91
  bcd_version: z.ZodNullable<z.ZodString>;
72
92
  verdict: z.ZodEnum<{
93
+ before_feature_support: "before_feature_support";
73
94
  flagged: "flagged";
95
+ no_feature_support: "no_feature_support";
74
96
  partial: "partial";
75
97
  prefixed: "prefixed";
76
98
  preview_only: "preview_only";
@@ -79,6 +101,22 @@ export declare const browsercompatCompareSupport: import("@cyanheads/mcp-ts-core
79
101
  }>;
80
102
  }, z.core.$strip>>;
81
103
  failing_total: z.ZodOptional<z.ZodNumber>;
104
+ failing_ranges: z.ZodOptional<z.ZodArray<z.ZodObject<{
105
+ agent: z.ZodString;
106
+ newest: z.ZodString;
107
+ oldest: z.ZodString;
108
+ count: z.ZodNumber;
109
+ verdict: z.ZodEnum<{
110
+ before_feature_support: "before_feature_support";
111
+ flagged: "flagged";
112
+ no_feature_support: "no_feature_support";
113
+ partial: "partial";
114
+ prefixed: "prefixed";
115
+ preview_only: "preview_only";
116
+ removed: "removed";
117
+ unsupported: "unsupported";
118
+ }>;
119
+ }, z.core.$strip>>>;
82
120
  evaluated_total: z.ZodOptional<z.ZodNumber>;
83
121
  evaluated_coverage_percent: z.ZodOptional<z.ZodNumber>;
84
122
  unchecked_total: z.ZodOptional<z.ZodNumber>;
@@ -90,13 +128,16 @@ export declare const browsercompatCompareSupport: import("@cyanheads/mcp-ts-core
90
128
  no_bcd_browser: "no_bcd_browser";
91
129
  no_bcd_data: "no_bcd_data";
92
130
  no_comparable_feature: "no_comparable_feature";
131
+ no_feature_level_data: "no_feature_level_data";
93
132
  unknown_version: "unknown_version";
94
133
  }>;
95
134
  usage_percent: z.ZodNumber;
96
135
  }, z.core.$strip>>>;
97
136
  compat_keys: z.ZodOptional<z.ZodArray<z.ZodString>>;
137
+ compat_keys_total: z.ZodOptional<z.ZodNumber>;
98
138
  guidance: z.ZodOptional<z.ZodString>;
99
139
  }, z.core.$strip>>;
140
+ omitted_features: z.ZodOptional<z.ZodArray<z.ZodString>>;
100
141
  all_clear: z.ZodBoolean;
101
142
  }, z.core.$strip>, readonly [{
102
143
  readonly reason: "invalid_target_query";
@@ -112,7 +153,7 @@ export declare const browsercompatCompareSupport: import("@cyanheads/mcp-ts-core
112
153
  }, {
113
154
  readonly reason: "invalid_feature_input";
114
155
  readonly code: JsonRpcErrorCode.ValidationError;
115
- readonly when: "An entry in features is whitespace-only. An empty or over-200-character entry is rejected against the input schema instead.";
156
+ readonly 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.";
116
157
  readonly 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.";
117
158
  }], {
118
159
  readonly data_version: z.ZodObject<{
@@ -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;;;;;;;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
+ {"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;AAwNjE,eAAO,MAAM,2BAA2B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA8lBtC,CAAC"}
@@ -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: z
28
- .enum(['partial', 'prefixed', 'flagged', 'removed', 'unsupported', 'preview_only'])
29
- .describe('Why this target failed: 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.'),
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,14 +66,20 @@ 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(['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.'),
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.'),
53
83
  usage_percent: z.number().describe('Share of tracked global traffic this target covers.'),
54
84
  });
55
85
  const ResultSchema = z.object({
@@ -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 spans more than one compat key or owns none.'),
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 five fields after it.'),
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()
@@ -93,20 +131,29 @@ const ResultSchema = z.object({
93
131
  compat_keys: z
94
132
  .array(z.string())
95
133
  .optional()
96
- .describe('Present on an ambiguous verdict — the browser-compat-data keys the feature owns. Re-run with one of them.'),
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 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.',
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.',
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(20)
109
- .describe('Up to 20 entries, each a browser-compat-data key such as css.selectors.has or a web-features id such as has, 1 to 200 characters. An empty or longer entry is rejected against this schema; a whitespace-only entry returns invalid_feature_input. Call browsercompat_search_features first for any entry whose key you do not already know.'),
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)
@@ -115,7 +162,7 @@ export const browsercompatCompareSupport = tool('browsercompat_compare_support',
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 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.'),
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(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.'),
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.'),
@@ -161,17 +208,23 @@ export const browsercompatCompareSupport = tool('browsercompat_compare_support',
161
208
  .number()
162
209
  .describe('Share of tracked global traffic covered by the targets counted in unchecked_targets_total.'),
163
210
  results: z
164
- .array(ResultSchema.describe('One result per input entry, in input order.'))
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.number().describe('The target_limit that was applied.'),
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()
@@ -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 onPage = new Set(tokens.slice(input.target_offset, input.target_offset + input.target_limit));
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
- /** Keyed by compat key, so a repeated entry is evaluated once. */
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
- if (key === null || leaf === undefined) {
299
- const compatKeys = resolution.compat_keys ?? [];
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
- compat_keys: compatKeys,
308
- guidance: compatKeys.length === 0
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(key);
459
+ let comparison = comparisons.get(subject.cacheKey);
315
460
  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;
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 Set([...comparisons.values()].flatMap((comparison) => comparison.unchecked
375
- .filter((target) => target.reason === 'no_bcd_data')
376
- .map((target) => tokenOf(target))));
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
- return withoutData.has(tokenOf(target)) ? [uncheckedRow(target, 'no_bcd_data')] : [];
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: input.target_limit, truncated });
518
+ ctx.enrich({ totalCount: tokens.length, shown, cap: pageSize, truncated });
391
519
  if (truncated)
392
520
  ctx.enrich({ nextOffset });
393
521
  if (shown === 0) {
@@ -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
- all_clear: results.every((result) => result.verdict === 'clears'),
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) => {
@@ -441,6 +571,7 @@ export const browsercompatCompareSupport = tool('browsercompat_compare_support',
441
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}%)`,
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
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`);
453
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('; ')}`);
593
+ }
454
594
  for (const target of item.failing_targets) {
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})`);
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.length === 0 ? 'none — this entry owns no browser-compat-data keys' : item.compat_keys.map(markdownText).join(', ')}`);
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)}`);