domain-hound 0.1.5 → 0.1.7

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 (39) hide show
  1. package/.agents/plugins/marketplace.json +1 -0
  2. package/.claude-plugin/marketplace.json +1 -0
  3. package/.claude-plugin/plugin.json +1 -1
  4. package/README.md +84 -13
  5. package/assets/readme-search.png +0 -0
  6. package/clis/domain-check/broker-atom.mjs +78 -0
  7. package/clis/domain-check/com-site.mjs +64 -25
  8. package/clis/domain-check/confirm.mjs +10 -5
  9. package/clis/domain-check/dossier.mjs +603 -0
  10. package/clis/domain-check/google-play.mjs +24 -11
  11. package/clis/domain-check/index.mjs +75 -23
  12. package/clis/domain-check/marketplaces.mjs +107 -0
  13. package/clis/domain-check/meaning-words.LICENSE.txt +408 -0
  14. package/clis/domain-check/meaning-words.json +2397 -0
  15. package/clis/domain-check/meaning.mjs +77 -0
  16. package/clis/domain-check/name-search.mjs +91 -14
  17. package/clis/domain-check/naming-method.mjs +6 -4
  18. package/clis/domain-check/registry.mjs +2 -2
  19. package/clis/domain-check/safe-web.mjs +207 -0
  20. package/clis/domain-check/trademarks.mjs +372 -0
  21. package/clis/domain-check/triage-sources.mjs +39 -12
  22. package/clis/domain-check/triage.mjs +190 -63
  23. package/clis/spaceship/buy.mjs +327 -0
  24. package/clis/spaceship/client.mjs +170 -0
  25. package/clis/spaceship/dns.mjs +292 -0
  26. package/clis/spaceship/quote.mjs +123 -0
  27. package/clis/spaceship/setup.mjs +81 -0
  28. package/clis/spaceship/store.mjs +104 -0
  29. package/clis/spaceship/tools.mjs +258 -0
  30. package/display.mjs +57 -30
  31. package/dossier.mjs +185 -0
  32. package/package.json +20 -2
  33. package/plugin.json +4 -3
  34. package/results-style.mjs +10 -0
  35. package/results.mjs +258 -62
  36. package/server.json +2 -2
  37. package/server.mjs +223 -96
  38. package/share.mjs +43 -0
  39. package/site/r/share-format.mjs +125 -0
@@ -1,9 +1,13 @@
1
- import { canRecommend, defaultEndings, eligibilityNotes, nameCandidates, normalizeName, searchCandidates, searchKey,
1
+ import { canRecommend, defaultEndings, eligibilityNotes, endingTier, nameCandidates, normalizeName, searchCandidates, searchKey,
2
2
  validEligibility, validEndings } from './name-search.mjs';
3
3
  import { shopSearchUrl } from './prices.mjs';
4
- import { checkHandles, compactText, handleSearches, letters, searchApps, searchEntities, searchMarks, trademarkSearches } from './triage-sources.mjs';
4
+ import { checkHandles, compactText, handleSearches, letters, markOrder, searchApps, searchEntities, searchMarks, trademarkSearches }
5
+ from './triage-sources.mjs';
6
+ import { checkOffice, officeAnswered, officeNames } from './trademarks.mjs';
7
+ import { screenMeaning } from './meaning.mjs';
5
8
  import { loadEdgarCompanies, matchEdgarCompanies, searchNorwegianCompanies } from './company-search.mjs';
6
9
  import { mapLimit } from './cache.mjs';
10
+ import { setTimeout as delay } from 'node:timers/promises';
7
11
  import { checkSocialHandles } from './handles.mjs';
8
12
  import { checkDomainSite } from './com-site.mjs';
9
13
  import { playSearchLink, searchAndroidApps } from './google-play.mjs';
@@ -140,22 +144,39 @@ function appStatus(ios, android) {
140
144
  + (android ? android.length ? taken('Android', android) : 'free on Android' : 'Android not checked');
141
145
  }
142
146
 
147
+ // US marks read as before; EU and Norwegian marks name their office and status first.
143
148
  function trademarkReason(mark) {
144
- return mark && mark.tier + ': ' + mark.name + ' (' + (mark.owner || 'owner unavailable') + ', '
149
+ const office = mark?.office && mark.office !== 'US' ? officeNames[mark.office] + ' ' + mark.status + ', ' : '';
150
+ return mark && mark.tier + ': ' + mark.name + ' (' + office + (mark.owner || 'owner unavailable') + ', '
145
151
  + (mark.classes.join('/') || 'class unavailable') + ')';
146
152
  }
147
153
 
148
- function verdict({ mark, otherMark, silent, ...evidence }) {
154
+ // The EU and Norwegian hits a person can open: office, mark, status, classes and the office's own record.
155
+ function officeMarkEntries(marks) {
156
+ const firstByOffice = Object.keys(officeNames).map(office => marks.find(mark => mark.office === office)).filter(Boolean);
157
+ const selected = [...firstByOffice, ...marks.filter(mark => !firstByOffice.includes(mark))].slice(0, 3).sort((a, b) =>
158
+ marks.indexOf(a) - marks.indexOf(b));
159
+ return selected.map(mark => ({ office: officeNames[mark.office], mark: mark.name,
160
+ tier: mark.tier, status: mark.status, classes: mark.classes, url: mark.url, ...(mark.checkedAt && { checkedAt: mark.checkedAt }) }));
161
+ }
162
+
163
+ function verdict({ mark, otherMark, silent, waiting = [], ...evidence }) {
149
164
  const [decision, reason] = baseVerdict({ mark, ...evidence });
150
165
  const trademark = trademarkReason(mark);
151
- const missing = silent.length ? silent.join(', ') + ' did not answer' : '';
166
+ const missing = [silent.length && silent.join(', ') + ' did not answer', waiting.length && 'still checking ' + waiting.join(', ')]
167
+ .filter(Boolean).join('; ');
152
168
  if (reason === 'A competition source did not answer' && missing) return [decision, missing];
169
+ // A clear verdict waits for the checks that are still running; the follow-up re-assesses it.
170
+ if (decision === 'No conflict found' && waiting.length) return ['Check first', missing];
153
171
  return [decision, [reason, trademark !== reason && trademark, trademarkReason(otherMark), missing].filter(Boolean).join(' · ')];
154
172
  }
155
173
 
156
- function silentSources({ marks, apps, android, entities, norway, edgar, github, handles }) {
174
+ function silentSources({ marks, offices, apps, android, entities, norway, edgar, github, handles }) {
157
175
  return Object.entries({
158
- USPTO: marks, 'App Store': apps, 'Google Play': android, Wikidata: entities, Brønnøysund: norway,
176
+ USPTO: marks,
177
+ ...Object.fromEntries(offices.filter(result => result.state !== 'off')
178
+ .map(result => [officeNames[result.office], officeAnswered(result) ? true : null])),
179
+ 'App Store': apps, 'Google Play': android, Wikidata: entities, Brønnøysund: norway,
159
180
  EDGAR: edgar, GitHub: github.status === 'check' ? null : github.status,
160
181
  npm: handles.npm === 'check' ? null : handles.npm,
161
182
  }).filter(([, value]) => value == null).map(([source]) => source);
@@ -222,7 +243,7 @@ export async function namePresence(input, options = {}) {
222
243
  // Same-name rivals with measured traction follow the traction rules first; evidence whose traction could not be
223
244
  // measured keeps the earlier same-name checks. Trademark and availability guardrails stay in place.
224
245
  function baseVerdict({ rival, overlap, sameName, activeApp, brand, app, entity, mark, site, best, available, marks, apps, android,
225
- androidAnswered = android, company, premium = [] }) {
246
+ androidAnswered = android, company, premium = [], offices = [] }) {
226
247
  if (rival?.[0] === 'Avoid') return rival;
227
248
  if (overlap) return ['Avoid', overlap.domain + ' is a live business in the same category'];
228
249
  if (activeApp) return ['Avoid', activeApp.name + ' is an app in the same category with ' + activeApp.ratings + ' ' + activeApp.store + ' ratings'];
@@ -237,12 +258,17 @@ function baseVerdict({ rival, overlap, sameName, activeApp, brand, app, entity,
237
258
  if (android?.length) return ['Check first', 'An exact-name Android app already exists'];
238
259
  if (site) return ['Check first', site.domain + ' has a live site under this name'];
239
260
  if (entity) return ['Check first', 'An exact-name Wikidata entity already exists'];
240
- if (!marks || !apps || !androidAnswered || sameName.unchecked?.length) return ['Check first', 'A competition source did not answer'];
261
+ const answeredOffices = offices.filter(result => result.state !== 'off');
262
+ if (!marks || !apps || !androidAnswered || sameName.unchecked?.length || !answeredOffices.every(officeAnswered)) {
263
+ return ['Check first', 'A competition source did not answer'];
264
+ }
241
265
  if (!best) {
242
266
  return ['Check first', available.length ? 'The free endings require buyer eligibility'
243
267
  : premium.length ? 'The free endings may be premium, price at shop' : 'No domain was found free at the registry'];
244
268
  }
245
- return ['No conflict found', 'No US mark, same-name app or active company found in the sources checked'];
269
+ const regions = ['US', ...answeredOffices.map(result => ({ EU: 'EU', NO: 'Norwegian' })[result.office])];
270
+ return ['No conflict found', 'No ' + regions.slice(0, -1).join(', ') + (regions.length > 1 ? ' or ' : '') + regions.at(-1)
271
+ + ' mark, same-name app or active company found in the sources checked'];
246
272
  }
247
273
 
248
274
  export async function triageNames(inputs, options = {}) {
@@ -253,6 +279,8 @@ export async function triageNames(inputs, options = {}) {
253
279
  if (options.endings && !validEndings(options.endings)) return { error: 'Choose supported domain endings.' };
254
280
  if (options.eligible !== undefined && !validEligibility(options.eligible)) return { error: 'Eligible endings must list supported restricted endings, such as no.' };
255
281
  const endings = options.endings ?? defaultEndings;
282
+ const preferred = options.preferredEndings ?? [];
283
+ const requestedEndings = [...preferred, ...(options.eligible ?? [])];
256
284
  const websiteEndings = [...new Set([...endings, ...coreWebsiteEndings])];
257
285
  // Each name has its DNS label (punycode for æøå) for domains, and a Latin key for the rival, app and mark sources.
258
286
  const names = new Map();
@@ -268,13 +296,35 @@ export async function triageNames(inputs, options = {}) {
268
296
  const timeLeft = () => budgetMs - (performance.now() - started);
269
297
  const signal = AbortSignal.timeout(budgetMs);
270
298
  const sources = { ...options, signal, timeLeft, cacheLifetime: evidenceLifetime, retryUnavailable: true, githubSearch: true };
271
- // Ask an unavailable source once more while the triage budget lasts.
272
- const retry = async (lookup, answered) => {
273
- const first = await lookup();
274
- return answered(first) || signal.aborted || timeLeft() < 300 ? first : lookup();
299
+ const retry = async (lookup, answered, waits = [0]) => {
300
+ let result = await lookup();
301
+ for (const wait of waits) {
302
+ if (answered(result) || signal.aborted || timeLeft() < wait + 300) break;
303
+ if (wait) await delay(wait);
304
+ if (!signal.aborted) result = await lookup();
305
+ }
306
+ return result;
275
307
  };
276
308
  const found = value => value != null;
277
- const traction = createTraction({ ...sources, refreshTranco: options.refreshTranco === true });
309
+ // A follow-up run calls triageNames twice with one memo. The first pass answers by options.answerAt with the checks
310
+ // done so far and lists the others as waiting; the second pass reuses every started lookup and re-assesses the names.
311
+ const memo = options.memo ?? new Map();
312
+ const once = (key, start) => {
313
+ if (!memo.has(key)) memo.set(key, start());
314
+ return memo.get(key);
315
+ };
316
+ const answerBy = options.answerAt == null ? null
317
+ : new Promise(resolve => setTimeout(resolve, Math.max(0, options.answerAt - performance.now())));
318
+ const waiting = new Map();
319
+ const wait = (index, source) => waiting.set(index, new Set([...waiting.get(index) ?? [], source]));
320
+ const waitingFor = index => [...new Set([...waiting.get('all') ?? [], ...waiting.get(index) ?? []])];
321
+ const byAnswer = (promise, index, source, fallback = null) => {
322
+ if (!answerBy) return promise;
323
+ let settled = false;
324
+ return Promise.race([promise.then(value => { settled = true; return value; }),
325
+ answerBy.then(() => { if (settled) return fallback; wait(index, source); return fallback; })]);
326
+ };
327
+ const traction = once('traction', () => createTraction({ ...sources, refreshTranco: options.refreshTranco === true }));
278
328
  const nameOf = new Map([...names.keys()].map((name, index) => [name, index]));
279
329
  // Start traction lookups as soon as a rival's home is known, so the slow free sources overlap the other checks.
280
330
  const startHomes = (name, domains, live = true) => {
@@ -294,8 +344,13 @@ export async function triageNames(inputs, options = {}) {
294
344
  const screened = entries.slice(0, screenLimit);
295
345
  const isScreened = index => index < screenLimit;
296
346
  const screenedDomains = new Set([...names.keys()].slice(0, screenLimit));
347
+ const sourceNames = new Map([[searchMarks, 'USPTO'], [searchApps, 'App Store'], [searchEntities, 'Wikidata'],
348
+ [searchNorwegianCompanies, 'Brønnøysund']]);
297
349
  const check = (concurrency, lookup, after = () => {}) => mapLimit(entries, concurrency, async ([name, input, index]) => {
298
- const result = signal.aborted || !isScreened(index) ? null : await retry(() => lookup(name, input, sources), found);
350
+ const source = sourceNames.get(lookup) ?? lookup.name;
351
+ const waits = lookup === searchApps || lookup === searchEntities ? [450 + index * 110, 1600 + index * 110] : [0];
352
+ const result = signal.aborted || !isScreened(index) ? null
353
+ : await byAnswer(once(source + ':' + name, () => retry(() => lookup(name, input, sources), found, waits)), index, source);
299
354
  after(result, index);
300
355
  return result;
301
356
  });
@@ -311,37 +366,55 @@ export async function triageNames(inputs, options = {}) {
311
366
  startHomes(name, (result ?? []).filter(row => row.brand).flatMap(row => (row.website ?? []).map(siteDomain))
312
367
  .filter(domain => domain?.split('.')[0].includes(name)));
313
368
  });
314
- const domainsDone = searchCandidates(groups, { ...options, budgetMs: Math.min(budgetMs, 11500),
315
- siteEndings: websiteEndings, siteTimeout: 3000, siteDetails: true, onSite,
316
- siteFilter: domain => screenedDomains.has(domain.slice(0, domain.indexOf('.'))) });
369
+ // A caller that already holds registry answers and site evidence (the broker dossier) passes them in, so the screen
370
+ // reuses them and makes no registry or site calls of its own.
371
+ const domainsDone = once('domains', () => options.domainSearch ? Promise.resolve().then(() => options.domainSearch(groups))
372
+ : searchCandidates(groups, { ...options, budgetMs: Math.min(budgetMs, 11500),
373
+ siteEndings: websiteEndings, siteTimeout: 3000, siteDetails: true, onSite,
374
+ siteFilter: domain => screenedDomains.has(domain.slice(0, domain.indexOf('.'))) }));
317
375
  // GitHub and npm accounts are same-name evidence for every screened name; they share one run of controls.
318
- const evidenceHandles = options.deferHandles ? Promise.resolve(new Map()) : checkSocialHandles(screened.map(([name]) => ({ name, platforms: ['GitHub', 'npm'], links: false })),
319
- { ...options, signal });
376
+ const evidenceHandles = options.deferHandles ? Promise.resolve(new Map()) : once('evidenceHandles', () => checkSocialHandles(screened.map(([name]) => ({ name, platforms: ['GitHub', 'npm'], links: false })),
377
+ { ...options, signal }));
320
378
  // Once the registry answers are in, the top three names get the full handle row, with Bluesky and variants.
321
- const handleRows = options.deferHandles || options.handleRows === false ? Promise.resolve(new Map()) : domainsDone.then(domains => {
379
+ const handleRows = options.deferHandles || options.handleRows === false ? Promise.resolve(new Map()) : once('handleRows', () => domainsDone.then(domains => {
322
380
  const order = handleOrder(domains.groups, keys, options.eligible).slice(0, handleLimit);
323
381
  options.onProgress?.({ stage: 'handles' });
324
382
  return evidenceHandles.then(() => checkSocialHandles(order.map(key => ({ name: key, variants: true })), { ...options, signal }));
325
- }).catch(() => new Map());
326
- const [domains, marksByName, appsByName, entitiesByName, handlesByName, norwayByName, androidApps, edgar, googleByName, socialByName] =
327
- await Promise.all([
383
+ }).catch(() => new Map()));
384
+ // Google Play answers per name, so the first pass keeps the names it has.
385
+ const playLive = once('playLive', () => new Map());
386
+ let playFinished = !answerBy;
387
+ const play = once('play', () => searchAndroidApps(new Map(screened.map(([key, input]) => [key, input])),
388
+ { ...sources, onResult: (name, apps) => playLive.set(name, apps),
389
+ playBudgetMs: Math.min(answerBy ? 20000 : 12000, options.playBudgetMs ?? Infinity, budgetMs) }));
390
+ const unverifiedHandles = { github: { status: 'check' }, handles: { GitHub: 'check', npm: 'check' } };
391
+ // Share the optional office lookups between passes and keep them off the first answer's critical path.
392
+ const officeCheck = office => mapLimit(entries, 4, ([name, input, index]) => isScreened(index)
393
+ ? byAnswer(once(office + ':' + name, () => checkOffice(office, name, input, sources)),
394
+ index, officeNames[office], { office, state: 'pending' }) : null);
395
+ const [domains, marksByName, appsByName, entitiesByName, handlesByName, norwayByName, androidApps, edgar, googleByName, socialByName,
396
+ euByName, noByName] = await Promise.all([
328
397
  // A cold cache still gets the bundled, dated list prices, so free endings never all read "price at shop".
329
- domainsDone,
398
+ // The second pass also collects the slow website checks.
399
+ options.memo && !answerBy ? domainsDone.then(async done => { await done.settleSites?.(); return done; }) : domainsDone,
330
400
  check(6, searchMarks), check(8, searchApps, (result, index) => startHomes(entries[index][0],
331
401
  (result ?? []).map(row => siteDomain(row.sellerUrl)).filter(domain => domain?.split('.')[0].includes(entries[index][0])))),
332
402
  entityChecks,
333
403
  Promise.all(entries.map(([name], index) => isScreened(index)
334
- ? checkHandles(name, { ...sources, social: evidenceHandles.then(rows => rows.get(name)).catch(() => null) }) : null)),
404
+ ? byAnswer(once('handles:' + name, () => checkHandles(name, {
405
+ ...sources, social: evidenceHandles.then(rows => rows.get(name)).catch(() => null),
406
+ })), index, 'GitHub repositories', unverifiedHandles) : null)),
335
407
  check(8, searchNorwegianCompanies),
336
- searchAndroidApps(new Map(screened.map(([key, input]) => [key, input])),
337
- { ...sources, playBudgetMs: Math.min(12000, options.playBudgetMs ?? Infinity, budgetMs) }),
338
- retry(() => loadEdgarCompanies(sources), found),
339
- mapLimit(entries, 5, ([name, input, index]) => isScreened(index) ? searchGoogle(name, input, {
408
+ answerBy ? Promise.race([play.then(map => [map, true]), answerBy.then(() => [new Map(playLive), false])])
409
+ .then(([map, done]) => { playFinished = done; return map; }) : play,
410
+ byAnswer(once('edgar', () => retry(() => loadEdgarCompanies(sources), found)), 'all', 'EDGAR'),
411
+ mapLimit(entries, 5, ([name, input, index]) => isScreened(index) ? byAnswer(once('google:' + name, () => searchGoogle(name, input, {
340
412
  ...sources, timeoutMs: timeLeft(),
341
413
  entities: entities[index].promise,
342
414
  sameBusiness: text => describedBusiness(name, text, options.about, options.category),
343
- }) : { unchecked: 'not screened' }),
415
+ })), index, 'Google', { unchecked: 'still checking' }) : { unchecked: 'not screened' }),
344
416
  handleRows,
417
+ officeCheck('EU'), officeCheck('NO'),
345
418
  ]);
346
419
  const counts = {};
347
420
  function coverage(source, answered) { counts[source] = (counts[source] ?? 0) + Number(answered); }
@@ -362,12 +435,16 @@ export async function triageNames(inputs, options = {}) {
362
435
  startEvidence(traction, rivals);
363
436
  return rivals;
364
437
  });
438
+ if (!playFinished) for (const [key, , index] of screened) if (!androidApps.has(key)) wait(index, 'Google Play');
365
439
  options.onProgress?.({ stage: 'rivals' });
366
- const evidence = await traction.settle();
440
+ // The first pass waits for rival traction only until its answer is due.
441
+ const evidence = await traction.settle(answerBy ? Math.max(150, timeLeft() - Math.max(0, options.answerAt - performance.now())) : undefined);
367
442
  const rows = domains.groups.map(({ name, results, sites }, index) => {
368
443
  const requested = results.filter(row => endings.includes(row.tld));
369
444
  const available = results.filter(row => row.status === 'probably-free' && endings.includes(row.tld));
370
- const recommendable = available.filter(row => canRecommend(row.tld, options.eligible));
445
+ const recommendable = available.filter(row => canRecommend(row.tld, options.eligible)
446
+ && (!preferred.length || preferred.includes(row.tld)));
447
+ if (preferred.length) recommendable.sort((a, b) => preferred.indexOf(a.tld) - preferred.indexOf(b.tld));
371
448
  const [best] = recommendable;
372
449
  const social = socialByName.get(keys.get(name)) ?? null;
373
450
  const domainFields = {
@@ -383,7 +460,8 @@ export async function triageNames(inputs, options = {}) {
383
460
  };
384
461
  const receipt = options.receipt && { _receiptEndings: requested.map(row => ({ domain: row.domain, source: row.source,
385
462
  checkedAt: row.checkedAt, priceAt: row.priceCheckedAt, shop: row.shop, checkout: row.buyUrl,
386
- site: sites[row.tld], risk: row.premium === 'risk' || row.premiumRisk })), _handles: social };
463
+ site: sites[row.tld], risk: row.premium === 'risk' || row.premiumRisk, ...(row.savings && { savings: row.savings }) })),
464
+ _handles: social, _waiting: () => isScreened(index) ? waitingFor(index) : [] };
387
465
  if (!isScreened(index)) {
388
466
  // Registry answers and prices only. The verdict never reads "No conflict found" without the checks.
389
467
  return {
@@ -417,8 +495,12 @@ export async function triageNames(inputs, options = {}) {
417
495
  const storeApps = storeAppsByName[index];
418
496
  const activeApp = storeApps.find(row => !explained.has(row.ref) && row.ratings >= 100 && describedBusiness(key,
419
497
  [row.name, row.category, row.description].join(' '), options.about, options.category));
420
- const mark = marks?.[0];
421
- const others = marks?.filter(item => letters(item.name) !== letters(mark?.name)) ?? [];
498
+ const offices = [euByName[index], noByName[index]].filter(Boolean);
499
+ const officeMarks = offices.flatMap(result => result.marks ?? []);
500
+ // US, EU and Norwegian hits share one order; a same-name mark at another office stays a separate hit.
501
+ const allMarks = [...(marks ?? []), ...officeMarks].sort(markOrder(key));
502
+ const mark = allMarks[0];
503
+ const others = allMarks.filter(item => item !== mark && (item.office !== mark?.office || letters(item.name) !== letters(mark?.name)));
422
504
  const otherMark = others.find(item => item.relevant) ?? others.find(item => item.tier === 'Fuzzy') ?? others[0];
423
505
  const seen = websiteEndings.flatMap(tld => {
424
506
  const row = results.find(result => result.tld === tld);
@@ -443,26 +525,43 @@ export async function triageNames(inputs, options = {}) {
443
525
  const sameName = sameNameEvidence({ name: key, live, norway, us, entities, entity, github, handles, deferHandles: options.deferHandles });
444
526
  const otherEntities = entities?.filter(row => !explained.has(row));
445
527
  const legacy = sameNameEvidence({ name: key, live: unmeasured, norway, us, entities: otherEntities, entity, github, handles, deferHandles: options.deferHandles });
446
- const silent = silentSources({ marks, apps, android, entities, norway, edgar, github, handles })
447
- .filter(source => !options.deferHandles || !['GitHub', 'npm'].includes(source));
528
+ // Taken endings whose website check is still running count as a waiting source.
529
+ const sitesWaiting = options.lateSiteMs > 0 && results.some(row => row.status === 'taken' && row.exact !== false
530
+ && websiteEndings.includes(row.tld) && !sites[row.tld]);
531
+ const sitesSilent = sitesWaiting || Object.values(sites).some(site => site?.state === 'unknown');
532
+ if (answerBy && sitesWaiting) wait(index, 'websites');
533
+ const pending = waitingFor(index);
534
+ const silent = silentSources({ marks, offices, apps, android, entities, norway, edgar, github, handles })
535
+ .filter(source => (!options.deferHandles || !['GitHub', 'npm'].includes(source)) && !pending.includes(source));
536
+ if (sitesSilent && !pending.includes('websites')) silent.push('websites');
448
537
  const otherEntity = otherEntities?.find(row => row.brand) ?? otherEntities?.[0];
449
538
  const [decision, reason] = verdict({
450
539
  rival: tractionVerdict(judged), overlap, sameName: legacy, activeApp,
451
540
  brand: otherEntity?.brand ? otherEntity : undefined, app: apps?.find(row => !explained.has(row)), entity: otherEntity,
452
- mark, otherMark, site, silent, best, available, marks, apps, premium: results.filter(row => row.status === 'premium'),
453
- android: android?.filter(row => !explained.has(row)), androidAnswered: android, company,
541
+ mark, otherMark, site, silent, waiting: pending, best, available, marks, apps, premium: results.filter(row => row.status === 'premium'),
542
+ android: android?.filter(row => !explained.has(row)), androidAnswered: android, company, offices,
454
543
  });
455
544
  const googleExplained = explainedGoogle(key, googleByName[index].raw, judged, entities);
456
545
  const summary = tractionSummary(judged);
457
546
  const answered = {
458
547
  USPTO: marks, 'App Store': apps, 'Google Play': android, Google: google.google, Wikidata: entities,
459
- Brønnøysund: norway, EDGAR: edgar,
548
+ Brønnøysund: norway, EDGAR: edgar, ...(options.memo && { Websites: sitesSilent ? null : true }),
549
+ ...Object.fromEntries(offices.filter(result => result.state !== 'off')
550
+ .map(result => [officeNames[result.office], officeAnswered(result) ? true : null])),
460
551
  ...!options.deferHandles && Object.fromEntries(Object.entries(handles).map(([service, status]) => [service, status === 'check' ? null : status])),
461
552
  };
462
553
  for (const [source, value] of Object.entries(answered)) coverage(source, value != null);
554
+ const usMark = marks?.[0];
463
555
  const competition = {
464
- US: mark ? trademarkReason(mark) : marks ? [] : null,
465
- mark: mark?.serial ? 'https://tsdr.uspto.gov/#caseNumber=' + mark.serial + '&caseSearchType=US_APPLICATION&caseType=DEFAULT&searchType=statusSearch' : null,
556
+ US: usMark ? trademarkReason(usMark) : marks ? [] : null,
557
+ mark: usMark?.url ?? null,
558
+ // EU and NO appear once a key is set: the strongest hit, [] when the office answered in full with none,
559
+ // null when it failed or answered in part (check yourself).
560
+ ...Object.fromEntries(offices.filter(result => result.state !== 'off').map(result => {
561
+ const best = result.marks?.[0];
562
+ return [result.office, officeAnswered(result) ? (best ? trademarkReason(best) : []) : null];
563
+ })),
564
+ ...(officeMarks.length > 0 && { marks: officeMarkEntries(officeMarks.sort(markOrder(key))) }),
466
565
  AppStore: app ? { name: app.name, developer: app.seller, ratings: app.ratings, url: app.url } : apps ? [] : null,
467
566
  GooglePlay: android?.map(({ name, seller, url, ratings }) => ({ name, developer: seller, url, ratings })).slice(0, 3) ?? null,
468
567
  Wikidata: entity ? { name: entity.name, description: entity.description, url: entity.url,
@@ -492,15 +591,27 @@ export async function triageNames(inputs, options = {}) {
492
591
  for (const row of rows) {
493
592
  // Google evidence that a measured rival explains is judged by its traction, not by the Google floor.
494
593
  if (!row._googleExplained) lowerVerdict(row, row.google);
594
+ // A rude or embarrassing meaning is a note and at most Check first, for every name, screened or not.
595
+ const meaning = screenMeaning(row.name);
596
+ if (meaning) {
597
+ row.meaning = meaning.note;
598
+ if (row.verdict === 'No conflict found') {
599
+ row.verdict = 'Check first';
600
+ row.reason = 'Meaning: ' + meaning.note + ' · ' + row.reason;
601
+ } else row.reason += ' · Meaning: ' + meaning.note;
602
+ }
495
603
  row.checks = options.compact ? null
496
604
  : nameCheckLines(row).map(({ label, text, link }) => label + ': ' + text + ' · ' + link);
497
605
  }
498
- for (const row of googleCandidates(rows)) row.google.search = true;
606
+ for (const row of googleCandidates(rows, requestedEndings)) row.google.search = true;
499
607
  const sourcesSummary = Object.fromEntries(Object.entries(counts).map(([source, answered]) =>
500
608
  [source, Math.round(100 * answered / Math.min(names.size, screenLimit))]));
501
- const receiptDetails = options.receipt ? structuredClone(rows.map(({ competition, details, traction, google, reason, _receiptEndings, _handles }) =>
502
- ({ competition, details, traction, google, reason, endings: _receiptEndings, handles: _handles }))) : null;
503
- const result = packTriage(rows, sourcesSummary, options.compact, endings, options.eligible);
609
+ const receiptDetails = options.receipt ? structuredClone(rows.map(({ competition, details, traction, google, reason, meaning, _receiptEndings, _handles, _waiting }) =>
610
+ ({ competition, details, traction, google, reason, meaning, endings: _receiptEndings, handles: _handles,
611
+ ...(_waiting?.().length && { waiting: _waiting() }) }))) : null;
612
+ const result = packTriage(rows, sourcesSummary, options.compact, endings, options.eligible, requestedEndings);
613
+ // The first pass of a follow-up run says more checks are coming.
614
+ if (answerBy && waiting.size) result.followUp = true;
504
615
  if (options.receipt) {
505
616
  result.checkedAt = (options.now ?? new Date()).toISOString();
506
617
  result.priceListDate = domains.priceDate?.slice(0, 10);
@@ -534,8 +645,8 @@ function compactHandles(entries) {
534
645
  }
535
646
 
536
647
  // The first three ranked names, filled from the screened names in input order when fewer than three rank.
537
- export function googleCandidates(rows) {
538
- const picked = rankedRows(rows).slice(0, 3);
648
+ export function googleCandidates(rows, requested) {
649
+ const picked = rankedRows(rows, requested).slice(0, 3);
539
650
  for (const row of rows) if (picked.length < 3 && !picked.includes(row)) picked.push(row);
540
651
  return picked;
541
652
  }
@@ -558,22 +669,33 @@ function likelyEndings(rows) {
558
669
  }
559
670
 
560
671
  // Best value is the lowest total of the payments due in three years; the cheaper first payment breaks a tie.
561
- function bestValue(options) {
672
+ export function bestValue(options) {
562
673
  return options.filter(row => Number.isFinite(row.threeYear)).reduce((best, row) => !best || row.threeYear < best.threeYear
563
674
  || (row.threeYear === best.threeYear && row.firstPayment < best.firstPayment) ? row : best, undefined);
564
675
  }
565
676
 
566
- function rankedRows(rows) {
677
+ // Best value within the most attractive tier that has an in-scope row. When that tier's rows lack a usable three-year
678
+ // total, there is no best value yet (it needs a shop quote); a fallback ending never takes over silently.
679
+ export function tierBestValue(options, requested = []) {
680
+ const tier = Math.min(...options.map(row => endingTier(row.domain, requested)));
681
+ return bestValue(options.filter(row => endingTier(row.domain, requested) === tier));
682
+ }
683
+
684
+ // A name's pick is its first recommendable row (ranked by tier, then upfront payment); a name without one sorts last.
685
+ const pickTier = (row, requested) => row._recommendable[0] ? endingTier(row._recommendable[0].domain, requested) : Infinity;
686
+
687
+ function rankedRows(rows, requested = []) {
567
688
  const order = { 'No conflict found': 0, 'Check first': 1 };
568
689
  return rows.filter(row => row.verdict !== 'Avoid').sort((a, b) => order[a.verdict] - order[b.verdict]
690
+ || pickTier(a, requested) - pickTier(b, requested)
569
691
  || (a._recommendable[0]?.firstPayment ?? Infinity) - (b._recommendable[0]?.firstPayment ?? Infinity));
570
692
  }
571
693
 
572
- function topChoices(rows) {
573
- return rankedRows(rows).slice(0, 3)
694
+ function topChoices(rows, requested) {
695
+ return rankedRows(rows, requested).slice(0, 3)
574
696
  .map(({ name, verdict, reason, _recommendable }) => {
575
697
  const [best] = _recommendable;
576
- const value = bestValue(_recommendable);
698
+ const value = tierBestValue(_recommendable, requested);
577
699
  return {
578
700
  name, verdict, reason, domain: best?.domain ?? null, ending: best?.tld ?? null,
579
701
  now: best?.firstPayment ?? null, renew: best?.renewalPayment ?? null, term: best?.minimumYears ?? null,
@@ -584,12 +706,12 @@ function topChoices(rows) {
584
706
  }
585
707
 
586
708
  // Share each ending's standard price once and keep only per-name differences.
587
- function packTriage(rows, sources, compact, endings, eligible) {
709
+ function packTriage(rows, sources, compact, endings, eligible, requested = []) {
588
710
  const prices = {};
589
- const top = topChoices(rows);
711
+ const top = topChoices(rows, requested);
590
712
  // Handle states for the top names: taken, not_found (no public profile found) or check (check yourself).
591
713
  const handles = Object.fromEntries(rows.filter(row => row._social).map(row => [row.name, row._social]));
592
- const names = rows.map(({ _free, _recommendable, _mark, _googleExplained, _receiptEndings, _handles, _social, ...row }) => {
714
+ const names = rows.map(({ _free, _recommendable, _mark, _googleExplained, _receiptEndings, _handles, _social, _waiting, ...row }) => {
593
715
  const own = {};
594
716
  for (const option of _free) {
595
717
  const entry = priceEntry(option);
@@ -597,7 +719,7 @@ function packTriage(rows, sources, compact, endings, eligible) {
597
719
  if (!prices[option.tld]) prices[option.tld] = entry;
598
720
  else if (JSON.stringify(prices[option.tld]) !== JSON.stringify(entry)) own[option.tld] = entry;
599
721
  }
600
- return { ...row, free: _free.map(option => option.tld), own, bestValue: bestValue(_recommendable)?.tld ?? null };
722
+ return { ...row, free: _free.map(option => option.tld), own, bestValue: tierBestValue(_recommendable, requested)?.tld ?? null };
601
723
  });
602
724
  const result = { top, names, prices, sources, eligibility: eligibilityNotes(endings),
603
725
  ...(Object.keys(handles).length && { handles }),
@@ -617,8 +739,9 @@ function packTriage(rows, sources, compact, endings, eligible) {
617
739
  row => { row.details = null; },
618
740
  row => { row.buy = null; },
619
741
  row => { if (row.traction) delete row.traction.geo; },
742
+ row => { if (row.competition.marks) row.competition.marks = row.competition.marks.slice(0, 1); },
620
743
  row => {
621
- const { sameName, mark, ...remaining } = row.competition;
744
+ const { sameName, mark, marks, ...remaining } = row.competition;
622
745
  row.competition = { ...remaining, mark: null, sameName: { level: sameName.level } };
623
746
  },
624
747
  row => {
@@ -633,7 +756,9 @@ function packTriage(rows, sources, compact, endings, eligible) {
633
756
  row => { delete row.google.why; },
634
757
  row => { row.name = normalizeName(row.name); },
635
758
  row => {
636
- if (typeof row.competition.US === 'string') row.competition.US = row.competition.US.split(':', 1)[0];
759
+ for (const office of ['US', 'EU', 'NO']) {
760
+ if (typeof row.competition[office] === 'string') row.competition[office] = row.competition[office].split(':', 1)[0];
761
+ }
637
762
  row.reason = row.reason.split(' · ', 1)[0];
638
763
  },
639
764
  // Last: the results page and say keep the full handle rows.
@@ -646,7 +771,7 @@ function packTriage(rows, sources, compact, endings, eligible) {
646
771
  const revised = new Map(rows.map(({ name }, index) => [name, names[index]]));
647
772
  for (const [index, row] of names.entries()) {
648
773
  row.reason = compactReason(row, rows[index]._mark, 60);
649
- if (typeof row.competition.US === 'string') row.competition.US = true;
774
+ for (const office of ['US', 'EU', 'NO']) if (typeof row.competition[office] === 'string') row.competition[office] = true;
650
775
  for (const source of ['AppStore', 'GooglePlay', 'Wikidata']) {
651
776
  if (typeof row.competition[source] === 'string') row.competition[source] = true;
652
777
  }
@@ -677,6 +802,8 @@ function compactReason(row, mark, budget) {
677
802
  const suffix = ', ' + (classes || 'class unavailable') + ')';
678
803
  const remaining = budget - Buffer.byteLength(prefix + ' (' + suffix);
679
804
  if (remaining < 6) return shortenBytes(row.reason, budget);
805
+ // A compact EU or Norwegian hit names its office in place of the owner.
806
+ const owner = mark.office && mark.office !== 'US' ? officeNames[mark.office] : mark.owner || 'owner unavailable';
680
807
  return prefix + shortenBytes(mark.name, Math.ceil(remaining / 2)) + ' ('
681
- + shortenBytes(mark.owner || 'owner unavailable', Math.floor(remaining / 2)) + suffix;
808
+ + shortenBytes(owner, Math.floor(remaining / 2)) + suffix;
682
809
  }