@astryxdesign/cli 0.7.2-canary.621784f → 0.7.2-canary.6a3ff0f

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 (143) hide show
  1. package/README.md +10 -10
  2. package/api/doctor/doctor.mjs +27 -3
  3. package/api/doctor/doctor.test.mjs +43 -0
  4. package/api/gap-report/gap-report.d.mts +3 -0
  5. package/api/gap-report/gap-report.doc.mjs +11 -3
  6. package/api/gap-report/gap-report.mjs +152 -48
  7. package/api/gap-report/gap-report.test.mjs +233 -0
  8. package/api/gap-report/gap-report.type.d.mts +41 -0
  9. package/api/gap-report/gap-report.type.mjs +18 -0
  10. package/api/integration/integrationComponentConflicts.doc.mjs +9 -3
  11. package/api/integration/validateIntegration.doc.mjs +3 -1
  12. package/api/search/search.d.mts +72 -12
  13. package/api/search/search.domain-priority.test.mjs +108 -18
  14. package/api/search/search.mjs +501 -37
  15. package/api/search/search.test.mjs +139 -0
  16. package/api/theme/build/build.family.test.mjs +54 -6
  17. package/api/theme/build/build.mjs +110 -13
  18. package/api/theme/themeBuild.doc.mjs +4 -4
  19. package/api/upgrade/_adapter.d.mts +40 -2
  20. package/api/upgrade/_adapter.mjs +117 -4
  21. package/api/upgrade/run/cli-behind-core.test.mjs +438 -0
  22. package/api/upgrade/run/run.mjs +30 -1
  23. package/api/upgrade/status/status.d.mts +21 -5
  24. package/api/upgrade/status/status.mjs +45 -8
  25. package/api/upgrade/upgrade.doc.mjs +5 -3
  26. package/api/upgrade/upgrade.type.d.mts +23 -0
  27. package/api/upgrade/upgrade.type.mjs +16 -1
  28. package/assets/codemods/runner.mjs +7 -1
  29. package/assets/docs/styling-overview.doc.mjs +1 -1
  30. package/assets/docs/tree/add-a-component.doc.mjs +1 -1
  31. package/assets/docs/tree/add-a-theme.doc.mjs +1 -1
  32. package/assets/docs/tree/add-a-topic.doc.mjs +10 -7
  33. package/assets/docs/tree/agent-guidance.doc.mjs +2 -2
  34. package/assets/docs/tree/block-template.doc.mjs +6 -18
  35. package/assets/docs/tree/build-the-template.doc.mjs +1 -1
  36. package/assets/docs/tree/check-the-props.doc.mjs +1 -1
  37. package/assets/docs/tree/check-your-docs.doc.mjs +10 -5
  38. package/assets/docs/tree/checks.doc.mjs +5 -5
  39. package/assets/docs/tree/codemods.doc.mjs +4 -4
  40. package/assets/docs/tree/component-family.doc.mjs +3 -5
  41. package/assets/docs/tree/component-imports.doc.mjs +2 -2
  42. package/assets/docs/tree/components.doc.mjs +1 -1
  43. package/assets/docs/tree/debug-and-gap-reports.doc.mjs +25 -16
  44. package/assets/docs/tree/define-the-theme.doc.mjs +6 -5
  45. package/assets/docs/tree/describe-the-component.doc.mjs +1 -1
  46. package/assets/docs/tree/docs.doc.mjs +3 -3
  47. package/assets/docs/tree/document-the-template.doc.mjs +1 -1
  48. package/assets/docs/tree/document-the-theme.doc.mjs +1 -1
  49. package/assets/docs/tree/export-template-assets.doc.mjs +1 -1
  50. package/assets/docs/tree/extend-or-replace.doc.mjs +6 -6
  51. package/assets/docs/tree/fonts-and-assets.doc.mjs +2 -2
  52. package/assets/docs/tree/generate-a-palette.doc.mjs +5 -3
  53. package/assets/docs/tree/grade-template-with-agent.doc.mjs +1 -1
  54. package/assets/docs/tree/integrations.doc.mjs +8 -0
  55. package/assets/docs/tree/links.doc.mjs +5 -4
  56. package/assets/docs/tree/migration-setup.doc.mjs +1 -0
  57. package/assets/docs/tree/migration-verification.doc.mjs +0 -1
  58. package/assets/docs/tree/migration.doc.mjs +0 -1
  59. package/assets/docs/tree/package-and-test.doc.mjs +1 -1
  60. package/assets/docs/tree/page-template.doc.mjs +3 -7
  61. package/assets/docs/tree/publishing.doc.mjs +1 -1
  62. package/assets/docs/tree/quick-start.doc.mjs +36 -20
  63. package/assets/docs/tree/replace-a-core-component.doc.mjs +4 -6
  64. package/assets/docs/tree/replace-a-core-template.doc.mjs +5 -7
  65. package/assets/docs/tree/sections-and-placement.doc.mjs +4 -6
  66. package/assets/docs/tree/see-it-in-an-app.doc.mjs +4 -2
  67. package/assets/docs/tree/short-and-findable.doc.mjs +6 -5
  68. package/assets/docs/tree/single-component.doc.mjs +12 -4
  69. package/assets/docs/tree/start-a-template.doc.mjs +3 -3
  70. package/assets/docs/tree/subcomponent.doc.mjs +6 -6
  71. package/assets/docs/tree/template-assets.doc.mjs +2 -2
  72. package/assets/docs/tree/template-doc-overview.doc.mjs +4 -15
  73. package/assets/docs/tree/template-fonts.doc.mjs +1 -1
  74. package/assets/docs/tree/template-icons.doc.mjs +1 -1
  75. package/assets/docs/tree/template-images-media.doc.mjs +1 -1
  76. package/assets/docs/tree/template-styles.doc.mjs +2 -2
  77. package/assets/docs/tree/templates.doc.mjs +1 -1
  78. package/assets/docs/tree/test-in-an-app.doc.mjs +3 -3
  79. package/assets/docs/tree/test-template-in-app.doc.mjs +1 -1
  80. package/assets/docs/tree/tokens-and-setup.doc.mjs +19 -15
  81. package/assets/docs/tree/troubleshooting.doc.mjs +4 -4
  82. package/assets/docs/tree/upgrading.doc.mjs +3 -3
  83. package/assets/docs/tree/use-a-theme-in-an-app.doc.mjs +3 -1
  84. package/assets/docs/tree/verify-packed-template.doc.mjs +1 -1
  85. package/assets/docs/tree/versioning.doc.mjs +6 -6
  86. package/assets/docs/tree/write-the-template-file.doc.mjs +2 -2
  87. package/authoring/codemod/codemod.doc.mjs +7 -3
  88. package/authoring/config/config.doc.mjs +9 -6
  89. package/authoring/config/type.ts +4 -2
  90. package/authoring/discover/discover.doc.mjs +1 -1
  91. package/authoring/doctypes/base/graph-fields.doc.mjs +6 -4
  92. package/authoring/doctypes/command/command.doc.mjs +14 -12
  93. package/authoring/doctypes/component/component.doc.mjs +28 -25
  94. package/authoring/doctypes/component/type.ts +7 -5
  95. package/authoring/doctypes/enum/enum.doc.mjs +7 -4
  96. package/authoring/doctypes/function/function.doc.mjs +9 -8
  97. package/authoring/doctypes/hook/hook.doc.mjs +5 -4
  98. package/authoring/doctypes/namespace/namespace.doc.mjs +7 -6
  99. package/authoring/doctypes/reference/reference.doc.mjs +11 -10
  100. package/authoring/doctypes/schema/schema.doc.mjs +9 -9
  101. package/authoring/doctypes/template/template.doc.mjs +2 -2
  102. package/authoring/doctypes/theme/theme.doc.mjs +2 -2
  103. package/authoring/gap-report/gap-report.doc.mjs +2 -2
  104. package/authoring/identity/identity.doc.mjs +3 -3
  105. package/authoring/integration/integration.doc.mjs +4 -3
  106. package/clients/cli/commands/build-theme.path-safety.test.mjs +155 -21
  107. package/clients/cli/commands/cli-postinstall.test.mjs +49 -1
  108. package/clients/cli/commands/doctor-integration-components.doc.mjs +3 -1
  109. package/clients/cli/commands/doctor-integration-validate.doc.mjs +3 -1
  110. package/clients/cli/commands/gap-report.doc.mjs +14 -2
  111. package/clients/cli/commands/gap-report.mjs +24 -2
  112. package/clients/cli/commands/gap-report.test.mjs +79 -0
  113. package/clients/cli/commands/integration-check.test.mjs +17 -0
  114. package/clients/cli/commands/integration.mjs +2 -3
  115. package/clients/cli/commands/setup-nudge.test.mjs +79 -1
  116. package/clients/cli/commands/swizzle.mjs +5 -3
  117. package/clients/cli/commands/swizzle.routing.test.mjs +18 -1
  118. package/clients/cli/commands/theme-build.doc.mjs +2 -2
  119. package/clients/cli/commands/upgrade.doc.mjs +14 -0
  120. package/clients/cli/commands/upgrade.older-cli.test.mjs +160 -0
  121. package/clients/cli/index.mjs +29 -5
  122. package/foundation/agent-docs/agent-doc-state.d.mts +14 -0
  123. package/foundation/agent-docs/agent-doc-state.mjs +38 -0
  124. package/foundation/agent-docs/agent-docs.d.mts +2 -1
  125. package/foundation/agent-docs/agent-docs.mjs +8 -6
  126. package/foundation/discovery/authoring-self-docs.mjs +1 -1
  127. package/foundation/discovery/doc-types.d.mts +1 -1
  128. package/foundation/discovery/doc-types.mjs +3 -3
  129. package/foundation/discovery/doc-types.test.mjs +48 -0
  130. package/foundation/discovery/project-typescript.d.mts +11 -2
  131. package/foundation/discovery/project-typescript.mjs +32 -4
  132. package/foundation/discovery/prop-drift.d.mts +1 -1
  133. package/foundation/discovery/prop-drift.mjs +2 -2
  134. package/foundation/discovery/prop-drift.test.mjs +55 -2
  135. package/foundation/discovery/type-text.mjs +1 -1
  136. package/foundation/discovery/type-text.test.mjs +1 -1
  137. package/foundation/doc-compiler/doc-loads.test.mjs +6 -2
  138. package/foundation/env/package-manager.d.mts +32 -0
  139. package/foundation/env/package-manager.mjs +47 -0
  140. package/foundation/env/package-manager.test.mjs +194 -7
  141. package/foundation/response/response-types.doc.mjs +5 -4
  142. package/package.json +9 -9
  143. package/scripts/postinstall.mjs +3 -3
@@ -7,6 +7,7 @@ import * as path from 'node:path';
7
7
  import {afterEach, beforeEach, describe, expect, it, vi} from 'vitest';
8
8
  import {Project} from '../../foundation/config/project.mjs';
9
9
  import {
10
+ ASK_DESTINATION_MESSAGE,
10
11
  GAP_REPORT_CATEGORIES,
11
12
  PUBLIC_CONFIRMATION_MESSAGE,
12
13
  collectGapReportHandlers,
@@ -1022,6 +1023,238 @@ console.log('https://github.com/acme/widgets/issues/42');
1022
1023
  });
1023
1024
  });
1024
1025
 
1026
+ describe('gapReport destinations and --to', () => {
1027
+ /** A shared internal handler that records each call in a marker file. */
1028
+ function addSharedHandler() {
1029
+ const marker = path.join(projectDir, 'shared-called');
1030
+ addIntegration({
1031
+ name: '@test/shared',
1032
+ audience: 'internal',
1033
+ handleBody: `(await import('node:fs')).writeFileSync(${JSON.stringify(marker)}, 'x'); return {status: 'filed', message: 'shared'};`,
1034
+ });
1035
+ return marker;
1036
+ }
1037
+
1038
+ function addWidgets(issuesUrl = 'https://github.com/acme/widgets/issues') {
1039
+ addIntegration({name: '@test/widgets', handler: false, issuesUrl});
1040
+ }
1041
+
1042
+ it('keeps the default route and lists the destinations with the ask line', async () => {
1043
+ const marker = addSharedHandler();
1044
+ addWidgets();
1045
+ configure(['@test/shared', '@test/widgets']);
1046
+ const argsFile = stubGh();
1047
+
1048
+ const result = await gapReport('General', {
1049
+ ...reportOptions,
1050
+ confirmPublic: true,
1051
+ cwd: projectDir,
1052
+ });
1053
+
1054
+ expect(result.data.deliveries).toEqual([
1055
+ expect.objectContaining({handler: '@test/shared', status: 'filed'}),
1056
+ ]);
1057
+ expect(fs.existsSync(marker)).toBe(true);
1058
+ expect(fs.existsSync(argsFile)).toBe(false);
1059
+ expect(result.data.destinations).toEqual([
1060
+ {to: null, default: true, issuesUrl: null},
1061
+ {
1062
+ to: '@test/widgets',
1063
+ default: false,
1064
+ issuesUrl: 'https://github.com/acme/widgets/issues',
1065
+ },
1066
+ ]);
1067
+ expect(result.data.ask).toBe(ASK_DESTINATION_MESSAGE);
1068
+ expect(ASK_DESTINATION_MESSAGE).toMatch(/ask the person/i);
1069
+ });
1070
+
1071
+ it('lists no destinations when no integration names an issuesUrl', async () => {
1072
+ addSharedHandler();
1073
+ configure(['@test/shared']);
1074
+
1075
+ const result = await gapReport('General', {
1076
+ ...reportOptions,
1077
+ cwd: projectDir,
1078
+ });
1079
+
1080
+ expect(result.data).not.toHaveProperty('destinations');
1081
+ expect(result.data).not.toHaveProperty('ask');
1082
+ });
1083
+
1084
+ it('files with the chosen integration GitHub issuesUrl only with consent, and runs no handler', async () => {
1085
+ const marker = addSharedHandler();
1086
+ addWidgets();
1087
+ configure(['@test/shared', '@test/widgets']);
1088
+ const argsFile = stubGh();
1089
+
1090
+ const pending = await gapReport('General', {
1091
+ ...reportOptions,
1092
+ to: '@test/widgets',
1093
+ cwd: projectDir,
1094
+ });
1095
+ expect(pending.data.deliveries).toEqual([
1096
+ {
1097
+ handlerType: 'fallback',
1098
+ handler: 'github',
1099
+ audience: 'public',
1100
+ status: 'consent_required',
1101
+ url: null,
1102
+ message: PUBLIC_CONFIRMATION_MESSAGE,
1103
+ },
1104
+ ]);
1105
+ expect(pending.data.issuesUrl).toBe(
1106
+ 'https://github.com/acme/widgets/issues',
1107
+ );
1108
+ expect(pending.data).not.toHaveProperty('destinations');
1109
+ expect(fs.existsSync(argsFile)).toBe(false);
1110
+
1111
+ const filed = await gapReport('General', {
1112
+ ...reportOptions,
1113
+ to: '@test/widgets',
1114
+ confirmPublic: true,
1115
+ cwd: projectDir,
1116
+ });
1117
+ expect(filed.data.deliveries).toHaveLength(1);
1118
+ expect(filed.data.deliveries[0]).toMatchObject({
1119
+ handlerType: 'fallback',
1120
+ handler: 'github',
1121
+ status: 'filed',
1122
+ });
1123
+ const args = JSON.parse(fs.readFileSync(argsFile, 'utf8'));
1124
+ expect(args.slice(0, 4)).toEqual([
1125
+ 'issue',
1126
+ 'create',
1127
+ '--repo',
1128
+ 'acme/widgets',
1129
+ ]);
1130
+ expect(fs.existsSync(marker)).toBe(false);
1131
+ });
1132
+
1133
+ it('routes a chosen non-GitHub issuesUrl as routed_only', async () => {
1134
+ addSharedHandler();
1135
+ addWidgets('https://tracker.example/widgets');
1136
+ configure(['@test/shared', '@test/widgets']);
1137
+
1138
+ const result = await gapReport('General', {
1139
+ ...reportOptions,
1140
+ to: '@test/widgets',
1141
+ cwd: projectDir,
1142
+ });
1143
+
1144
+ expect(result.data.deliveries).toEqual([
1145
+ expect.objectContaining({
1146
+ handlerType: 'fallback',
1147
+ handler: 'issuesUrl',
1148
+ status: 'routed_only',
1149
+ url: 'https://tracker.example/widgets',
1150
+ }),
1151
+ ]);
1152
+ expect(result.data.status).toBe('routed_only');
1153
+ });
1154
+
1155
+ it.each([
1156
+ ['a package that is not loaded', '@test/nope'],
1157
+ ['a loaded integration without an issuesUrl', '@test/shared'],
1158
+ ])(
1159
+ 'refuses --to naming %s, lists the choices, and sends nothing',
1160
+ async (_label, to) => {
1161
+ const marker = addSharedHandler();
1162
+ addWidgets();
1163
+ configure(['@test/shared', '@test/widgets']);
1164
+
1165
+ await expect(
1166
+ gapReport('General', {...reportOptions, to, cwd: projectDir}),
1167
+ ).rejects.toMatchObject({
1168
+ code: 'ERR_UNKNOWN_PACKAGE',
1169
+ suggestions: [
1170
+ {
1171
+ name: '@test/widgets',
1172
+ reason: 'https://github.com/acme/widgets/issues',
1173
+ },
1174
+ ],
1175
+ });
1176
+ expect(fs.existsSync(marker)).toBe(false);
1177
+ },
1178
+ );
1179
+
1180
+ it.each([
1181
+ ['an empty value', ''],
1182
+ ['a blank value', ' '],
1183
+ ['an over-long value', `@test/${'a'.repeat(300)}`],
1184
+ ])('refuses %s for --to with the destination list', async (_label, to) => {
1185
+ const marker = addSharedHandler();
1186
+ addWidgets();
1187
+ configure(['@test/shared', '@test/widgets']);
1188
+
1189
+ await expect(
1190
+ gapReport('General', {...reportOptions, to, cwd: projectDir}),
1191
+ ).rejects.toMatchObject({
1192
+ code: 'ERR_UNKNOWN_PACKAGE',
1193
+ suggestions: [{name: '@test/widgets'}],
1194
+ });
1195
+ expect(fs.existsSync(marker)).toBe(false);
1196
+ });
1197
+
1198
+ it('treats to: null as absent', async () => {
1199
+ const marker = addSharedHandler();
1200
+ addWidgets();
1201
+ configure(['@test/shared', '@test/widgets']);
1202
+
1203
+ const result = await gapReport('General', {
1204
+ ...reportOptions,
1205
+ to: /** @type {any} */ (null),
1206
+ cwd: projectDir,
1207
+ });
1208
+
1209
+ expect(result.data.deliveries).toHaveLength(1);
1210
+ expect(fs.existsSync(marker)).toBe(true);
1211
+ expect(result.data.destinations).toHaveLength(2);
1212
+ });
1213
+
1214
+ it('lists the destinations with the categories', async () => {
1215
+ addSharedHandler();
1216
+ addWidgets();
1217
+ configure(['@test/shared', '@test/widgets']);
1218
+
1219
+ const listed = await gapReport(undefined, {
1220
+ listCategories: true,
1221
+ cwd: projectDir,
1222
+ });
1223
+
1224
+ expect(listed.data).toEqual(GAP_REPORT_CATEGORIES);
1225
+ expect(listed.meta).toEqual({
1226
+ destinations: [
1227
+ {to: null, default: true, issuesUrl: null},
1228
+ {
1229
+ to: '@test/widgets',
1230
+ default: false,
1231
+ issuesUrl: 'https://github.com/acme/widgets/issues',
1232
+ },
1233
+ ],
1234
+ ask: ASK_DESTINATION_MESSAGE,
1235
+ });
1236
+ });
1237
+
1238
+ it('adds no meta to the categories when there is only the default', async () => {
1239
+ configure([]);
1240
+ const listed = await gapReport(undefined, {
1241
+ listCategories: true,
1242
+ cwd: projectDir,
1243
+ });
1244
+ expect(listed).not.toHaveProperty('meta');
1245
+ });
1246
+
1247
+ it('refuses --to with --list-categories', async () => {
1248
+ await expect(
1249
+ gapReport(undefined, {
1250
+ listCategories: true,
1251
+ to: '@test/widgets',
1252
+ cwd: projectDir,
1253
+ }),
1254
+ ).rejects.toMatchObject({code: 'ERR_INVALID_ARGUMENT'});
1255
+ });
1256
+ });
1257
+
1025
1258
  describe('gapReport target selection', () => {
1026
1259
  it('routes to the unique component owner', async () => {
1027
1260
  addIntegration({
@@ -35,10 +35,42 @@ export type GapReportOptions = {
35
35
  * Return the category vocabulary without routing or writing.
36
36
  */
37
37
  listCategories?: boolean | undefined;
38
+ /**
39
+ * A destination the person chose: a loaded integration
40
+ * whose manifest names an issues URL. The report goes only there.
41
+ */
42
+ to?: string | undefined;
43
+ };
44
+ /**
45
+ * Where a report can go. The default entry (`to: null`) is the configured
46
+ * handlers, or with none the owning package's issues URL.
47
+ */
48
+ export type GapReportDestination = {
49
+ /**
50
+ * The value to pass as `to`; null for the default.
51
+ */
52
+ to: string | null;
53
+ /**
54
+ * Whether this is the default destination.
55
+ */
56
+ default: boolean;
57
+ /**
58
+ * The integration's issues URL; null for the
59
+ * default.
60
+ */
61
+ issuesUrl: string | null;
38
62
  };
39
63
  export type GapReportCategoriesResponse = {
40
64
  type: "gap-report.categories";
41
65
  data: GapReportCategoryEntry[];
66
+ /**
67
+ * Present when a destination besides the default exists: every destination,
68
+ * and the line telling an agent to ask the person.
69
+ */
70
+ meta?: {
71
+ destinations: GapReportDestination[];
72
+ ask: string;
73
+ } | undefined;
42
74
  };
43
75
  export type GapReportAggregateStatus = "filed" | "partial" | "failed" | "routed_only" | "consent_required" | "skipped";
44
76
  export type GapReportDeliveryStatus = "filed" | "routed_only" | "skipped" | "failed" | "consent_required";
@@ -81,6 +113,15 @@ export type GapReportReceipt = {
81
113
  * Count of handlers that routed only.
82
114
  */
83
115
  routedOnlyCount: number;
116
+ /**
117
+ * For a run without `to`,
118
+ * when a destination besides the default exists: every destination.
119
+ */
120
+ destinations?: GapReportDestination[] | undefined;
121
+ /**
122
+ * With `destinations`: ask the person where to file.
123
+ */
124
+ ask?: string | undefined;
84
125
  };
85
126
  export type GapReportReceiptResponse = {
86
127
  type: "gap-report.file";
@@ -23,12 +23,27 @@
23
23
  * @property {string} [package] Explicit owner package for ambiguous routes.
24
24
  * @property {boolean} [confirmPublic] Explicit consent for public handlers or GitHub issue creation.
25
25
  * @property {boolean} [listCategories] Return the category vocabulary without routing or writing.
26
+ * @property {string} [to] A destination the person chose: a loaded integration
27
+ * whose manifest names an issues URL. The report goes only there.
28
+ */
29
+
30
+ /**
31
+ * Where a report can go. The default entry (`to: null`) is the configured
32
+ * handlers, or with none the owning package's issues URL.
33
+ * @typedef {object} GapReportDestination
34
+ * @property {string|null} to The value to pass as `to`; null for the default.
35
+ * @property {boolean} default Whether this is the default destination.
36
+ * @property {string|null} issuesUrl The integration's issues URL; null for the
37
+ * default.
26
38
  */
27
39
 
28
40
  /**
29
41
  * @typedef {object} GapReportCategoriesResponse
30
42
  * @property {'gap-report.categories'} type
31
43
  * @property {GapReportCategoryEntry[]} data
44
+ * @property {{destinations: GapReportDestination[], ask: string}} [meta]
45
+ * Present when a destination besides the default exists: every destination,
46
+ * and the line telling an agent to ask the person.
32
47
  */
33
48
 
34
49
  /**
@@ -58,6 +73,9 @@
58
73
  * @property {GapReportDelivery[]} deliveries Ordered handler outcomes.
59
74
  * @property {number} filedCount Count of handlers that filed the report.
60
75
  * @property {number} routedOnlyCount Count of handlers that routed only.
76
+ * @property {GapReportDestination[]} [destinations] For a run without `to`,
77
+ * when a destination besides the default exists: every destination.
78
+ * @property {string} [ask] With `destinations`: ask the person where to file.
61
79
  */
62
80
 
63
81
  /**
@@ -18,7 +18,9 @@ export const doc = {
18
18
  'replaces is checked too: its findings are issues, errors for a package that ' +
19
19
  'declares the CLI range that turns replacement on and warnings otherwise. ' +
20
20
  "Each component doc's props are compared with the component's TypeScript props, " +
21
- "read with the project's own `typescript`: a documented prop the code lacks, a " +
21
+ "read with the project's own `typescript` (or, where `typescript` is missing or has no " +
22
+ 'JavaScript compiler API, as TypeScript 7 does, the `@typescript/typescript6` it ' +
23
+ 'installs): a documented prop the code lacks, a ' +
22
24
  'prop the package declares that the doc omits, a wrong `required`, or a type ' +
23
25
  'that does not match. A type is judged only when it reads exactly: the same ' +
24
26
  'text as the source, once whitespace, quotes and union order are set aside (exactly, if it contains `readonly`), ' +
@@ -50,14 +52,18 @@ export const doc = {
50
52
  'drift',
51
53
  ],
52
54
  params: [
53
- {name: 'pkg', type: 'string', description: 'Installed package; omit for the local package.'},
55
+ {
56
+ name: 'pkg',
57
+ type: 'string',
58
+ description: 'Installed package; omit for the local package.',
59
+ },
54
60
  {name: 'options.cwd', type: 'string', description: 'Resolution directory.'},
55
61
  ],
56
62
  returns: [
57
63
  {
58
64
  type: 'integration.component-conflicts',
59
65
  description:
60
- '`validated` (false when no integration manifest was found, so nothing was inspected), integration identity, structural and replaces issues, and Core component-name conflicts with package-qualified commands. An active replacement that keeps the Core name it replaces is not a conflict. When the manifest loads and declares a components root, `propDrift` holds the props comparison: `status` (`checked` | `skipped`), `reason` when skipped, `typescript`, `components` compared, `typesCompared` (documented prop types judged), `typesSkipped` (why none was, with a TypeScript older than 4.8), `findings` ({component, prop, kind: `not_in_code` | `not_in_doc` | `required_mismatch` | `type_mismatch`, severity: `warning`, message, doc, source, docType?, codeType?, docRequired?, codeRequired?}), `unchecked` ({component, doc, reason}), `typesNotCompared` ({component, doc, reason, props}: every other documented prop type, grouped by why it was not judged: not a form the check judges exactly (a doc type that does not parse, or a prop a mapped type builds from keys the check cannot trace, included), a field the prop\'s variants give different types, a standard prop such as `className`, or a prop declared outside the package), and `propsNotChecked` when a mapped type builds props from keys the check cannot trace to the package ({component, doc, reason, props}: no warning is drawn for those props).',
66
+ "`validated` (false when no integration manifest was found, so nothing was inspected), integration identity, structural and replaces issues, and Core component-name conflicts with package-qualified commands. An active replacement that keeps the Core name it replaces is not a conflict. When the manifest loads and declares a components root, `propDrift` holds the props comparison: `status` (`checked` | `skipped`), `reason` when skipped, `typescript`, `components` compared, `typesCompared` (documented prop types judged), `typesSkipped` (why none was, with a TypeScript older than 4.8), `findings` ({component, prop, kind: `not_in_code` | `not_in_doc` | `required_mismatch` | `type_mismatch`, severity: `warning`, message, doc, source, docType?, codeType?, docRequired?, codeRequired?}), `unchecked` ({component, doc, reason}), `typesNotCompared` ({component, doc, reason, props}: every other documented prop type, grouped by why it was not judged: not a form the check judges exactly (a doc type that does not parse, or a prop a mapped type builds from keys the check cannot trace, included), a field the prop's variants give different types, a standard prop such as `className`, or a prop declared outside the package), and `propsNotChecked` when a mapped type builds props from keys the check cannot trace to the package ({component, doc, reason, props}: no warning is drawn for those props).",
61
67
  },
62
68
  ],
63
69
  examples: [
@@ -26,7 +26,9 @@ export const doc = {
26
26
  'can stay exit-0 in a non-integration directory. It also checks every doc the ' +
27
27
  'package ships under its roots (component, template, docs topic, theme, and translation, served or not) against ' +
28
28
  "the published authoring type for its kind, as `tsc` would, with the project's " +
29
- 'own `typescript`: an unknown field, a missing required field, or a value outside ' +
29
+ 'own `typescript` (or, where `typescript` is missing or has no JavaScript compiler ' +
30
+ 'API, as TypeScript 7 does, the `@typescript/typescript6` it installs): an unknown ' +
31
+ 'field, a missing required field, or a value outside ' +
30
32
  "a field's type is a warning in `docTypes` naming the field and a fix. A test " +
31
33
  'fixture under `__tests__` in the components or docs root is counted, not checked. ' +
32
34
  'Without TypeScript, `docTypes` is `skipped` with a reason.',
@@ -16,6 +16,48 @@ export function stem(w: string): string;
16
16
  * @returns {boolean}
17
17
  */
18
18
  export function sameWord(a: string, b: string): boolean;
19
+ /**
20
+ * A query with its camelCase and PascalCase identifiers spelled as words, so
21
+ * `SidebarToggle` reads "sidebar toggle" and `useTablePaginationState` "use
22
+ * table pagination state". Plain words, and identifiers joined with `_` or `-`, are
23
+ * unchanged: a joined token that matches nothing stays unmatched.
24
+ * @param {string} query - The query as typed, before lowercasing.
25
+ * @returns {string} Lowercased.
26
+ */
27
+ export function spellIdentifiers(query: string): string;
28
+ /**
29
+ * The strongest hit a run of two or more adjacent query words has when it is
30
+ * read as one joined word, and the query words it covers. Readers type a
31
+ * compound name as separate words (`table header cell` is TableHeaderCell,
32
+ * `number field` the keyword `numberfield`), and no single word of the run
33
+ * matches on its own.
34
+ *
35
+ * - 100: the run joins to a component, hook, or template name, or its plural
36
+ * (`table header cells` is TableHeaderCell), or a hook name without its
37
+ * `use` prefix (`table sticky columns` is useTableStickyColumns).
38
+ * - 90: the run joins to a one-word keyword (`number field` is
39
+ * `numberfield`).
40
+ * - 95: the run joins to most of a name, cut short (`dropdown menu radio` is
41
+ * DropdownMenuRadioItem); 92: it is a name's leading words, covering at least half
42
+ * of it (`top nav mega` is TopNavMegaMenu); 70: it is two or more adjacent
43
+ * words of a name that cover at least half of it (`header cell` in
44
+ * TableHeaderCell), the same coverage a word prefix needs. These three
45
+ * are for components and hooks only.
46
+ *
47
+ * A doc's name is a route or key, so docs are left out.
48
+ * @param {string[]} words - The query's words, stopwords included.
49
+ * @param {Candidate} candidate
50
+ * @returns {{score: number, reason: string, covered: Set<string>, alias?: 'partial' | 'keyword', aliasWords?: number} | null}
51
+ * `covered` holds the run's words and every stretch of them joined. `alias`
52
+ * marks a hit on part of a name or on a keyword, not on the whole name.
53
+ */
54
+ export function compoundHit(words: string[], candidate: Candidate): {
55
+ score: number;
56
+ reason: string;
57
+ covered: Set<string>;
58
+ alias?: "partial" | "keyword";
59
+ aliasWords?: number;
60
+ } | null;
19
61
  /**
20
62
  * Split a query into meaningful content tokens (lowercased, stopwords + very
21
63
  * short words removed). Empty for single-word queries (callers fall back to
@@ -40,19 +82,20 @@ export function tokenizeQuery(term: string): string[];
40
82
  * typography/font-setup, `side panel` is "Side panels");
41
83
  * - 1: a word of the query is the topic's name (`illustration` in a longer
42
84
  * question is the illustrations guide);
85
+ * - 1: a query of two or more words is one of the topic's own declared
86
+ * keywords, whatever the plural (`code review` on a guide that declares it);
43
87
  * - 1: the query holds one of the doc's titles whole (`resizable side panels`
44
88
  * names "Side panels"; `light dark mode button` names "Light/Dark Mode");
45
89
  * - 1: the doc matches every word of the query and one of them is a word of
46
90
  * its title (`switch to a dark theme` and "Use a theme").
47
91
  * A section answers to its topic's name.
48
92
  *
49
- * A doc that matched only by keyword, by a heading holding the query, or by
93
+ * A doc that matched only by a heading holding the query, by one word, or by
50
94
  * words spread through its text has no priority. Docs are split into many
51
- * small topics, and each declares its own keywords and headings, so a common
52
- * phrase such as `font size` hits a guide's keyword or heading exactly
53
- * (170-190) while the component the reader is after matches one word by
54
- * keyword (`Text`, 98). Ranked on text alone, every split adds another doc
55
- * above the component. Broad reference pages match every word of many queries
95
+ * small topics, each with its own headings, so a common phrase such as
96
+ * `font size` hits a heading exactly (170) while the component the reader is
97
+ * after matches one word by keyword (`Text`, 98). Ranked on text alone, every
98
+ * split adds another doc above the component. Broad reference pages match every word of many queries
56
99
  * in their text the same way. The score stays the text-match strength the
57
100
  * result reports, so callers that gate on it (`build`) see the same numbers.
58
101
  *
@@ -67,7 +110,7 @@ export function domainPriority(term: string, tokens: string[], candidate: Candid
67
110
  score: number;
68
111
  matched: number;
69
112
  total: number;
70
- }): 0 | 1 | 2;
113
+ }, queryWords?: string[]): 0 | 1 | 2;
71
114
  /**
72
115
  * The first title or heading that holds every word of the query, in order and
73
116
  * side by side, or null.
@@ -89,18 +132,26 @@ export function titleInQuery(term: string, titles: string[] | undefined): string
89
132
  * @param {string} term - Lowercased full query.
90
133
  * @param {string[]} tokens - Content tokens from tokenizeQuery(term).
91
134
  * @param {Candidate} candidate
92
- * @returns {{score: number, reason: string, matched: number, total: number} | null}
135
+ * @param {string[]} [words] - The query's words for compound names (see
136
+ * compoundHit); empty when the query names an entry outright.
137
+ * @param {{plain?: boolean}} [opts] - `plain`: score without matches on part
138
+ * of a name or a joined keyword.
139
+ * @returns {{score: number, reason: string, matched: number, total: number, alias?: 'partial' | 'keyword', aliasWords?: number} | null}
93
140
  * `matched`/`total` are the query concepts this candidate answered, out of
94
141
  * the concepts the query had. Callers that must distinguish "matched one word
95
142
  * of three" from "matched all three" — `build`, which gates its pages group
96
143
  * on coverage — cannot recover that from the score, because a single strong
97
144
  * hit and a broad weak one land on the same number.
98
145
  */
99
- export function scoreQuery(term: string, tokens: string[], candidate: Candidate): {
146
+ export function scoreQuery(term: string, tokens: string[], candidate: Candidate, words?: string[], { plain }?: {
147
+ plain?: boolean;
148
+ }): {
100
149
  score: number;
101
150
  reason: string;
102
151
  matched: number;
103
152
  total: number;
153
+ alias?: "partial" | "keyword";
154
+ aliasWords?: number;
104
155
  } | null;
105
156
  /**
106
157
  * Score a single candidate against the search term across name, keywords,
@@ -118,8 +169,9 @@ export function scoreQuery(term: string, tokens: string[], candidate: Candidate)
118
169
  * @param {string} [candidate.description]
119
170
  * @param {string[]} [candidate.prose] - Extra free-text blobs (doc section text, best practices).
120
171
  * @param {string[]} [candidate.guidance] - Usage guidance (features, best practices) — scored a tier below description.
121
- * @param {{fuzzy?: boolean}} [opts] - `fuzzy`: allow edit-distance (typo) matches. Default true; multi-word queries pass false.
122
- * @returns {{score: number, reason: string} | null}
172
+ * @param {{fuzzy?: boolean, joins?: boolean}} [opts] - `fuzzy`: allow edit-distance (typo) matches. Default true; multi-word queries pass false. `joins`: read a spaced query joined into a name or keyword (default true); off when the query names an entry outright.
173
+ * @returns {{score: number, reason: string, alias?: 'partial' | 'keyword'} | null}
174
+ * `alias` marks a hit that read the query's words joined.
123
175
  */
124
176
  export function scoreCandidate(term: string, { name, aliases, domain, keywords, weakKeywords, description, prose, guidance, }: {
125
177
  name: string;
@@ -130,11 +182,13 @@ export function scoreCandidate(term: string, { name, aliases, domain, keywords,
130
182
  description?: string | undefined;
131
183
  prose?: string[] | undefined;
132
184
  guidance?: string[] | undefined;
133
- }, { fuzzy }?: {
185
+ }, { fuzzy, joins }?: {
134
186
  fuzzy?: boolean;
187
+ joins?: boolean;
135
188
  }): {
136
189
  score: number;
137
190
  reason: string;
191
+ alias?: "partial" | "keyword";
138
192
  } | null;
139
193
  /**
140
194
  * The components (name and keywords) a search response was scored against, or
@@ -213,6 +267,12 @@ export type Candidate = {
213
267
  */
214
268
  aliases?: string[] | undefined;
215
269
  keywords?: string[] | undefined;
270
+ /**
271
+ * - A doc's own declared keywords: what its
272
+ * author lists in `keywords`, without the code terms and table cells its
273
+ * other keywords add.
274
+ */
275
+ _declared?: string[] | undefined;
216
276
  weakKeywords?: string[] | undefined;
217
277
  description?: string | undefined;
218
278
  prose?: string[] | undefined;