domain-hound 0.1.8 → 0.1.9

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.
@@ -1,5 +1,6 @@
1
- import { canRecommend, comparePicks, defaultEndings, eligibilityNotes, nameCandidates, pickName, normalizeName, searchCandidates, searchKey,
2
- validEligibility, validEndings } from './name-search.mjs';
1
+ import { canRecommend, comparePicks, defaultEndings, eligibilityNotes, nameCandidates, pickName, normalizeName, searchCandidates,
2
+ searchKey, validEligibility, validEndings } from './name-search.mjs';
3
+ import { compactScore, compareScores, scoreEligible, scoreHandles, scoreName, validCandidate } from './name-score.mjs';
3
4
  import { shopSearchUrl } from './prices.mjs';
4
5
  import { checkHandles, compactText, handleSearches, letters, markOrder, searchApps, searchEntities, searchMarks, trademarkSearches }
5
6
  from './triage-sources.mjs';
@@ -10,7 +11,7 @@ import { mapLimit } from './cache.mjs';
10
11
  import { setTimeout as delay } from 'node:timers/promises';
11
12
  import { checkSocialHandles } from './handles.mjs';
12
13
  import { checkDomainSite } from './com-site.mjs';
13
- import { playSearchLink, searchAndroidApps } from './google-play.mjs';
14
+ import { playSearchLink } from './google-play.mjs';
14
15
  import { googleSearchLink, lowerVerdict, nameCheckLines, searchGoogle } from './google-search.mjs';
15
16
  import { autocompleteWords, collectRivals, createTraction, evidenceLifetime, judgeRivals, parseGeo, siteDomain, startEvidence,
16
17
  tractionNotes, tractionSummary, tractionVerdict } from './traction.mjs';
@@ -73,6 +74,13 @@ function describedBusiness(name, text, about, category) {
73
74
  (pattern.test(description) || (!about && stem.test(name))) && pattern.test(descriptor));
74
75
  }
75
76
 
77
+ // The caller's evidence for one name (triage_names candidates), matched by DNS label like geo. Invalid entries count as missing.
78
+ function candidateFor(candidates, name) {
79
+ if (!candidates || typeof candidates !== 'object') return {};
80
+ const entry = Object.entries(candidates).find(([key]) => normalizeName(key) === name)?.[1];
81
+ return validCandidate(entry) ? entry : {};
82
+ }
83
+
76
84
  export function memorability(name, input) {
77
85
  const parts = input.replace(/([a-z])([A-Z])/g, '$1 $2').toLowerCase()
78
86
  .normalize('NFKD').replace(/\p{M}/gu, '').match(/[a-z]+/g) ?? [];
@@ -88,7 +96,7 @@ export function memorability(name, input) {
88
96
  }
89
97
 
90
98
  function siteEvidence(row, site) {
91
- if (row?.status === 'probably-free') return 'Registry free';
99
+ if (row?.status === 'probably-free') return 'Available at the registry';
92
100
  if (row?.status !== 'taken') return 'Registry unresolved';
93
101
  if (site?.state === 'live') return site.title ? 'Live: ' + compactText(site.title, 75) : 'Live site';
94
102
  if (site?.state === 'for-sale' || row.forSale) return 'Taken, possible resale';
@@ -138,10 +146,9 @@ function sameNameEvidence({ name, live, norway, us, entities, entity, github, ha
138
146
  };
139
147
  }
140
148
 
141
- function appStatus(ios, android) {
149
+ function appStatus(ios) {
142
150
  const taken = (store, matches) => 'taken on ' + store + (matches[0].seller ? ' (' + matches[0].seller + ')' : '');
143
- return 'App name: ' + (ios ? ios.length ? taken('iOS', ios) : 'free on iOS' : 'iOS not checked') + ', '
144
- + (android ? android.length ? taken('Android', android) : 'free on Android' : 'Android not checked');
151
+ return 'App name: ' + (ios ? ios.length ? taken('iOS', ios) : 'free on iOS' : 'iOS not checked');
145
152
  }
146
153
 
147
154
  // US marks read as before; EU and Norwegian marks name their office and status first.
@@ -171,12 +178,12 @@ function verdict({ mark, otherMark, silent, waiting = [], ...evidence }) {
171
178
  return [decision, [reason, trademark !== reason && trademark, trademarkReason(otherMark), missing].filter(Boolean).join(' · ')];
172
179
  }
173
180
 
174
- function silentSources({ marks, offices, apps, android, entities, norway, edgar, github, handles }) {
181
+ function silentSources({ marks, offices, apps, entities, norway, edgar, github, handles }) {
175
182
  return Object.entries({
176
183
  USPTO: marks,
177
184
  ...Object.fromEntries(offices.filter(result => result.state !== 'off')
178
185
  .map(result => [officeNames[result.office], officeAnswered(result) ? true : null])),
179
- 'App Store': apps, 'Google Play': android, Wikidata: entities, Brønnøysund: norway,
186
+ 'App Store': apps, Wikidata: entities, Brønnøysund: norway,
180
187
  EDGAR: edgar, GitHub: github.status === 'check' ? null : github.status,
181
188
  npm: handles.npm === 'check' ? null : handles.npm,
182
189
  }).filter(([, value]) => value == null).map(([source]) => source);
@@ -200,13 +207,19 @@ function explainedGoogle(name, raw, judged, entities) {
200
207
  && (words === 0 || judged.rivals.some(row => row.level !== 'unknown' && row.rival.autocomplete === words && words > 0));
201
208
  }
202
209
 
210
+ function googleRival(google, explained, subjectKnown) {
211
+ if (explained || !google?.result || google.result === 'open') return [];
212
+ const owned = google.result.startsWith('owned by');
213
+ return [{ level: 'some', sameSubject: owned && google.sameBusiness ? true : owned && !subjectKnown ? null : false }];
214
+ }
215
+
203
216
  // The applet's fast domain lookup stays independent of the slower name checks.
204
217
  export async function namePresence(input, options = {}) {
205
218
  const name = normalizeName(input);
206
219
  if (!name) return { error: 'Enter one name without a domain ending.' };
207
220
  const started = performance.now();
208
221
  const timeLeft = () => 8500 - (performance.now() - started);
209
- const sources = { ...options, signal: AbortSignal.timeout(8500), playBudgetMs: 8000, timeLeft, cacheLifetime: evidenceLifetime };
222
+ const sources = { ...options, signal: AbortSignal.timeout(8500), timeLeft, cacheLifetime: evidenceLifetime };
210
223
  const traction = createTraction({ ...sources, refreshTranco: options.refreshTranco === true });
211
224
  const entityCheck = searchEntities(name, input, sources);
212
225
  const siteChecks = mapLimit(coreWebsiteEndings, 3, async ending => {
@@ -215,19 +228,17 @@ export async function namePresence(input, options = {}) {
215
228
  if (site?.state === 'live') traction.evidence(domain);
216
229
  return [ending, site];
217
230
  });
218
- const [ios, android, google, entities, website] = await Promise.all([
231
+ const [ios, google, entities, website] = await Promise.all([
219
232
  searchApps(name, input, sources),
220
- searchAndroidApps(new Map([[name, input]]), sources),
221
233
  searchGoogle(name, input, { ...sources, entities: entityCheck }),
222
234
  entityCheck, siteChecks,
223
235
  ]);
224
236
  // The applet has no agent: Wikipedia/Wikidata presence stands in for GEO and is labelled so.
225
- const apps = [...(ios ?? []).map(row => ({ ...row, store: 'iOS' })),
226
- ...(android.get(name) ?? []).map(row => ({ ...row, store: 'Android' }))];
237
+ const apps = (ios ?? []).map(row => ({ ...row, store: 'iOS' }));
227
238
  const rivals = collectRivals({ name, input, sites: Object.fromEntries(website), entities, topics: google.raw?.topics, suggestions: google.raw?.suggestions, apps });
228
239
  startEvidence(traction, rivals);
229
240
  const judged = judgeRivals(rivals, await traction.settle(400), { now: (options.now ?? new Date()).getTime(),
230
- answered: { wikidata: entities != null, apps: ios != null && android.has(name) }, entities });
241
+ answered: { wikidata: entities != null, apps: ios != null }, entities });
231
242
  const summary = tractionSummary(judged);
232
243
  const notes = tractionNotes(judged);
233
244
  return { name, ...(summary && { traction: summary }), ...(notes.length && { notes }), checks: nameCheckLines({
@@ -235,15 +246,14 @@ export async function namePresence(input, options = {}) {
235
246
  google: google.google,
236
247
  competition: {
237
248
  AppStore: ios?.map(({ name, seller, ratings }) => ({ name, developer: seller, ratings })),
238
- GooglePlay: android.get(name)?.map(({ name, seller, ratings }) => ({ name, developer: seller, ratings })),
239
249
  },
240
250
  }) };
241
251
  }
242
252
 
243
253
  // Same-name rivals with measured traction follow the traction rules first; evidence whose traction could not be
244
254
  // measured keeps the earlier same-name checks. Trademark and availability guardrails stay in place.
245
- function baseVerdict({ rival, overlap, sameName, activeApp, brand, app, entity, mark, site, best, available, marks, apps, android,
246
- androidAnswered = android, company, premium = [], offices = [] }) {
255
+ function baseVerdict({ rival, overlap, sameName, activeApp, brand, app, entity, mark, site, best, available, marks, apps,
256
+ company, premium = [], offices = [] }) {
247
257
  if (rival?.[0] === 'Avoid') return rival;
248
258
  if (overlap) return ['Avoid', overlap.domain + ' is a live business in the same category'];
249
259
  if (activeApp) return ['Avoid', activeApp.name + ' is an app in the same category with ' + activeApp.ratings + ' ' + activeApp.store + ' ratings'];
@@ -255,16 +265,15 @@ function baseVerdict({ rival, overlap, sameName, activeApp, brand, app, entity,
255
265
  if (mark) return ['Check first', trademarkReason(mark)];
256
266
  if (sameName.level !== 'few') return ['Check first', 'Several public sources show same-name use'];
257
267
  if (app) return ['Check first', 'An exact-name app already exists'];
258
- if (android?.length) return ['Check first', 'An exact-name Android app already exists'];
259
268
  if (site) return ['Check first', site.domain + ' has a live site under this name'];
260
269
  if (entity) return ['Check first', 'An exact-name Wikidata entity already exists'];
261
270
  const answeredOffices = offices.filter(result => result.state !== 'off');
262
- if (!marks || !apps || !androidAnswered || sameName.unchecked?.length || !answeredOffices.every(officeAnswered)) {
271
+ if (!marks || !apps || sameName.unchecked?.length || !answeredOffices.every(officeAnswered)) {
263
272
  return ['Check first', 'A competition source did not answer'];
264
273
  }
265
274
  if (!best) {
266
- return ['Check first', available.length ? 'The free endings require buyer eligibility'
267
- : premium.length ? 'The free endings may be premium, price at shop' : 'No domain was found free at the registry'];
275
+ return ['Check first', available.length ? 'The available endings require buyer eligibility'
276
+ : premium.length ? 'The available endings may be premium, price at shop' : 'The registry did not confirm an available domain'];
268
277
  }
269
278
  const regions = ['US', ...answeredOffices.map(result => ({ EU: 'EU', NO: 'Norwegian' })[result.office])];
270
279
  return ['No conflict found', 'No ' + regions.slice(0, -1).join(', ') + (regions.length > 1 ? ' or ' : '') + regions.at(-1)
@@ -381,18 +390,12 @@ export async function triageNames(inputs, options = {}) {
381
390
  options.onProgress?.({ stage: 'handles' });
382
391
  return evidenceHandles.then(() => checkSocialHandles(order.map(key => ({ name: key, variants: true })), { ...options, signal }));
383
392
  }).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
393
  const unverifiedHandles = { github: { status: 'check' }, handles: { GitHub: 'check', npm: 'check' } };
391
394
  // Share the optional office lookups between passes and keep them off the first answer's critical path.
392
395
  const officeCheck = office => mapLimit(entries, 4, ([name, input, index]) => isScreened(index)
393
396
  ? byAnswer(once(office + ':' + name, () => checkOffice(office, name, input, sources)),
394
397
  index, officeNames[office], { office, state: 'pending' }) : null);
395
- const [domains, marksByName, appsByName, entitiesByName, handlesByName, norwayByName, androidApps, edgar, googleByName, socialByName,
398
+ const [domains, marksByName, appsByName, entitiesByName, handlesByName, norwayByName, edgar, googleByName, socialByName,
396
399
  euByName, noByName] = await Promise.all([
397
400
  // A cold cache still gets the bundled, dated list prices, so free endings never all read "price at shop".
398
401
  // The second pass also collects the slow website checks.
@@ -405,8 +408,6 @@ export async function triageNames(inputs, options = {}) {
405
408
  ...sources, social: evidenceHandles.then(rows => rows.get(name)).catch(() => null),
406
409
  })), index, 'GitHub repositories', unverifiedHandles) : null)),
407
410
  check(8, searchNorwegianCompanies),
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
411
  byAnswer(once('edgar', () => retry(() => loadEdgarCompanies(sources), found)), 'all', 'EDGAR'),
411
412
  mapLimit(entries, 5, ([name, input, index]) => isScreened(index) ? byAnswer(once('google:' + name, () => searchGoogle(name, input, {
412
413
  ...sources, timeoutMs: timeLeft(),
@@ -419,10 +420,7 @@ export async function triageNames(inputs, options = {}) {
419
420
  const counts = {};
420
421
  function coverage(source, answered) { counts[source] = (counts[source] ?? 0) + Number(answered); }
421
422
  const geoByName = new Map(Object.entries(options.geo ?? {}).map(([key, value]) => [normalizeName(key), parseGeo(value)]));
422
- const storeAppsByName = domains.groups.map(({ name }, index) => [
423
- ...(appsByName[index] ?? []).map(row => ({ ...row, store: 'iOS', ref: row })),
424
- ...(androidApps.get(keys.get(name)) ?? []).map(row => ({ ...row, store: 'Android', ref: row })),
425
- ]);
423
+ const storeAppsByName = appsByName.map(apps => (apps ?? []).map(row => ({ ...row, store: 'iOS', ref: row })));
426
424
  const rivalsByName = domains.groups.map(({ name, sites }, index) => {
427
425
  if (!isScreened(index)) return [];
428
426
  const raw = googleByName[index].raw ?? {};
@@ -435,7 +433,6 @@ export async function triageNames(inputs, options = {}) {
435
433
  startEvidence(traction, rivals);
436
434
  return rivals;
437
435
  });
438
- if (!playFinished) for (const [key, , index] of screened) if (!androidApps.has(key)) wait(index, 'Google Play');
439
436
  options.onProgress?.({ stage: 'rivals' });
440
437
  // The first pass waits for rival traction only until its answer is due.
441
438
  const evidence = await traction.settle(answerBy ? Math.max(150, timeLeft() - Math.max(0, options.answerAt - performance.now())) : undefined);
@@ -487,10 +484,9 @@ export async function triageNames(inputs, options = {}) {
487
484
  const brand = entities?.find(row => row.brand);
488
485
  const entity = brand ?? entities?.[0];
489
486
  const key = keys.get(name);
490
- const android = androidApps.get(key);
491
487
  const google = googleByName[index];
492
488
  const judged = judgeRivals(rivalsByName[index], evidence, { now: (options.now ?? new Date()).getTime(),
493
- answered: { wikidata: entities != null, apps: apps != null && android != null },
489
+ answered: { wikidata: entities != null, apps: apps != null },
494
490
  geo: geoByName.get(name), entities });
495
491
  const { explained } = judged;
496
492
  const storeApps = storeAppsByName[index];
@@ -532,7 +528,7 @@ export async function triageNames(inputs, options = {}) {
532
528
  const sitesSilent = sitesWaiting || Object.values(sites).some(site => site?.state === 'unknown');
533
529
  if (answerBy && sitesWaiting) wait(index, 'websites');
534
530
  const pending = waitingFor(index);
535
- const silent = silentSources({ marks, offices, apps, android, entities, norway, edgar, github, handles })
531
+ const silent = silentSources({ marks, offices, apps, entities, norway, edgar, github, handles })
536
532
  .filter(source => (!options.deferHandles || !['GitHub', 'npm'].includes(source)) && !pending.includes(source));
537
533
  if (sitesSilent && !pending.includes('websites')) silent.push('websites');
538
534
  const otherEntity = otherEntities?.find(row => row.brand) ?? otherEntities?.[0];
@@ -540,12 +536,12 @@ export async function triageNames(inputs, options = {}) {
540
536
  rival: tractionVerdict(judged), overlap, sameName: legacy, activeApp,
541
537
  brand: otherEntity?.brand ? otherEntity : undefined, app: apps?.find(row => !explained.has(row)), entity: otherEntity,
542
538
  mark, otherMark, site, silent, waiting: pending, best, available, marks, apps, premium: results.filter(row => row.status === 'premium'),
543
- android: android?.filter(row => !explained.has(row)), androidAnswered: android, company, offices,
539
+ company, offices,
544
540
  });
545
541
  const googleExplained = explainedGoogle(key, googleByName[index].raw, judged, entities);
546
542
  const summary = tractionSummary(judged);
547
543
  const answered = {
548
- USPTO: marks, 'App Store': apps, 'Google Play': android, Google: google.google, Wikidata: entities,
544
+ USPTO: marks, 'App Store': apps, Google: google.google, Wikidata: entities,
549
545
  Brønnøysund: norway, EDGAR: edgar, ...(options.memo && { Websites: sitesSilent ? null : true }),
550
546
  ...Object.fromEntries(offices.filter(result => result.state !== 'off')
551
547
  .map(result => [officeNames[result.office], officeAnswered(result) ? true : null])),
@@ -557,19 +553,58 @@ export async function triageNames(inputs, options = {}) {
557
553
  US: usMark ? trademarkReason(usMark) : marks ? [] : null,
558
554
  mark: usMark?.url ?? null,
559
555
  // EU and NO appear once a key is set: the strongest hit, [] when the office answered in full with none,
560
- // null when it failed or answered in part (check yourself).
556
+ // null when it failed or answered in part.
561
557
  ...Object.fromEntries(offices.filter(result => result.state !== 'off').map(result => {
562
558
  const best = result.marks?.[0];
563
559
  return [result.office, officeAnswered(result) ? (best ? trademarkReason(best) : []) : null];
564
560
  })),
565
561
  ...(officeMarks.length > 0 && { marks: officeMarkEntries(officeMarks.sort(markOrder(key))) }),
566
562
  AppStore: app ? { name: app.name, developer: app.seller, ratings: app.ratings, url: app.url } : apps ? [] : null,
567
- GooglePlay: android?.map(({ name, seller, url, ratings }) => ({ name, developer: seller, url, ratings })).slice(0, 3) ?? null,
563
+ GooglePlay: null,
568
564
  Wikidata: entity ? { name: entity.name, description: entity.description, url: entity.url,
569
565
  ...(entity.brand && { brand: true }) } : entities ? [] : null,
570
566
  sameName,
571
567
  };
568
+ // Name score evidence. A source that did not answer is null, one the follow-up still runs is 'pending'.
569
+ const state = (answer, ...sources) => answer != null ? 'ok' : sources.some(source => pending.includes(source)) ? 'pending' : null;
570
+ const subjectKnown = Boolean(options.about || options.category);
571
+ const euSandbox = (options.env ?? process.env).DOMAIN_HOUND_EUIPO_SANDBOX === '1';
572
+ const eu = euSandbox ? undefined : offices.find(result => result.office === 'EU');
573
+ const rivalSources = ['Google', 'Wikidata', 'App Store', 'websites'];
574
+ const rivalsAnswered = google.google != null && entities != null && apps != null && !sitesSilent
575
+ && judged.rivals.every(row => row.level !== 'unknown');
576
+ const sameSectorCompany = norway?.matches.some(({ match, homepage }) => {
577
+ const domain = siteDomain(homepage);
578
+ return match === 'exact' && domain && judged.rivals.some(({ rival }) =>
579
+ rival.sameBusiness && rival.domains.includes(domain));
580
+ }) ?? false;
581
+ const scoreInput = {
582
+ name: names.get(name), candidate: candidateFor(options.candidates, name),
583
+ // Free endings in scope with a registry answer (never DNS alone) and their payments due in 3 years.
584
+ domains: recommendable.filter(row => row.status === 'probably-free' && ['rdap', 'whois'].includes(row.source))
585
+ .map(row => ({ ending: row.tld, total: row.threeYear ?? null, registry: true })),
586
+ marks: { us: state(marks, 'USPTO') ?? 'unknown',
587
+ eu: eu && officeAnswered(eu) ? 'ok' : eu && pending.includes(officeNames.EU) ? 'pending' : eu?.state === 'off' || !eu ? 'off' : 'unknown',
588
+ list: allMarks.filter(item => !euSandbox || item.office !== 'EU').map(item => ({ tier: item.tier, live: item.live === true ? true : item.live === false ? false : null,
589
+ // Classes unknown: null. Only a verified class overlap can hard-filter.
590
+ sameClass: !item.classes?.length ? null : (item.relevantClasses?.length ?? 0) > 0 })) },
591
+ // Measured rivals count even when another source failed; the state says whether the rival check is complete.
592
+ // A registry homepage links an exact-name company to an independently checked site in the same subject.
593
+ rivals: { state: rivalsAnswered ? 'ok' : rivalSources.some(source => pending.includes(source)) ? 'pending' : 'unknown',
594
+ list: [...judged.rivals.filter(row => row.level !== 'unknown').map(row => ({ level: row.dormant ? 'dormant' : row.level,
595
+ sameSubject: subjectKnown ? Boolean(row.rival.sameBusiness) : null })),
596
+ // Web search evidence no measured rival explains: one brand owning the results, or several uses, counts as
597
+ // a same-name use with some traction (in your subject when the search says so).
598
+ ...googleRival(google.google, explainedGoogle(key, google.raw, judged, entities), subjectKnown)], company: sameSectorCompany },
599
+ apps: { state: state(apps, 'App Store') ?? 'unknown',
600
+ list: storeApps.map(row => ({ sameCategory: subjectKnown
601
+ ? describedBusiness(key, [row.name, row.category, row.description].join(' '), options.about, options.category) : null })) },
602
+ handles: options.deferHandles ? {} : social ? scoreHandles(social)
603
+ : Object.fromEntries(Object.entries(handles).map(([platform, value]) => [platform,
604
+ value === 'taken' ? 'taken' : value === 'not-found' ? 'free' : null])),
605
+ };
572
606
  return {
607
+ _scoreInput: scoreInput,
573
608
  // Small and dormant same-name uses are notes after the reason; they never change the verdict.
574
609
  name: names.get(name), verdict: decision, reason: [reason, ...tractionNotes(judged)].join(' · '),
575
610
  _free: available, _recommendable: recommendable, _pick: best, _mark: mark, _googleExplained: googleExplained,
@@ -584,8 +619,8 @@ export async function triageNames(inputs, options = {}) {
584
619
  memorable: memorability(key, names.get(name)),
585
620
  presence: Object.fromEntries(Object.entries(handles).map(([service, status]) =>
586
621
  [service, status === 'check' ? null : status])),
587
- sites: Object.fromEntries(seen), appName: appStatus(apps, android),
588
- AndroidSearch: android ? null : playSearchLink(names.get(name)),
622
+ sites: Object.fromEntries(seen), appName: appStatus(apps),
623
+ AndroidSearch: playSearchLink(names.get(name)),
589
624
  },
590
625
  };
591
626
  });
@@ -602,14 +637,29 @@ export async function triageNames(inputs, options = {}) {
602
637
  } else row.reason += ' · Meaning: ' + meaning.note;
603
638
  }
604
639
  row.checks = options.compact ? null
605
- : nameCheckLines(row).map(({ label, text, link }) => label + ': ' + text + ' · ' + link);
640
+ : nameCheckLines(row).map(({ label, text, link, linkLabel }) =>
641
+ (linkLabel ? text + ' · ' + linkLabel : label + ': ' + text) + ' · ' + link);
642
+ // Only the fully screened names get a Name score; bans and hard filters run first, inside scoreName.
643
+ if (row._scoreInput) {
644
+ row._scoreInput.meaning = meaning ? { how: meaning.how } : null;
645
+ row._score = scoreName(row._scoreInput);
646
+ // A legacy Avoid stays a guard. The one exception: the only Avoid is a strong rival with affirmative evidence of a
647
+ // different subject; the score carries that penalty, so the name may still rank.
648
+ const rivals = row._scoreInput.rivals.list;
649
+ if (row._score.value != null && row.verdict === 'Avoid' && /^David vs Goliath: /.test(row.reason) && !row.google?.sameBusiness
650
+ && rivals.some(rival => rival.level === 'strong') && rivals.every(rival => rival.level !== 'strong' || rival.sameSubject === false)) {
651
+ row._score.overridesAvoid = true;
652
+ }
653
+ row.score = compactScore(row._score);
654
+ }
606
655
  }
607
656
  for (const row of googleCandidates(rows, requestedEndings, options.eligible, options.upfrontCap)) row.google.search = true;
608
657
  const sourcesSummary = Object.fromEntries(Object.entries(counts).map(([source, answered]) =>
609
658
  [source, Math.round(100 * answered / Math.min(names.size, screenLimit))]));
610
- const receiptDetails = options.receipt ? structuredClone(rows.map(({ competition, details, traction, google, reason, meaning, _receiptEndings, _handles, _waiting }) =>
659
+ const receiptDetails = options.receipt ? structuredClone(rows.map(({ competition, details, traction, google, reason, meaning, _receiptEndings, _handles, _waiting,
660
+ _score, _scoreInput }) =>
611
661
  ({ competition, details, traction, google, reason, meaning, endings: _receiptEndings, handles: _handles,
612
- ...(_waiting?.().length && { waiting: _waiting() }) }))) : null;
662
+ ...(_waiting?.().length && { waiting: _waiting() }), ...(_score && { score: _score, scoreInput: _scoreInput }) }))) : null;
613
663
  const result = packTriage(rows, sourcesSummary, options.compact, endings, options.eligible, requestedEndings, options.upfrontCap);
614
664
  // The first pass of a follow-up run says more checks are coming.
615
665
  if (answerBy && waiting.size) result.followUp = true;
@@ -641,7 +691,7 @@ export function handleOrder(groups, keys, eligible) {
641
691
  function compactHandles(entries) {
642
692
  if (!Array.isArray(entries)) return null;
643
693
  const by = state => entries.filter(entry => entry.state === state).map(entry => entry.platform);
644
- const [taken, notFound, check] = [by('taken'), by('not-found'), by('check')];
694
+ const [taken, notFound, check] = [by('taken'), by('not-found'), by('unknown')];
645
695
  return { ...(taken.length && { taken }), ...(notFound.length && { not_found: notFound }), ...(check.length && { check }) };
646
696
  }
647
697
 
@@ -677,9 +727,11 @@ export function bestValue(options) {
677
727
 
678
728
  const pickOption = ({ _pick }) => _pick && { domain: _pick.domain, now: _pick.firstPayment, total: _pick.threeYear };
679
729
 
730
+ // Score-ranked picks come first. Unscreened names use the previous verdict and domain order.
680
731
  function rankedRows(rows, requested = [], eligible = [], budget) {
681
732
  const order = { 'No conflict found': 0, 'Check first': 1 };
682
- return rows.filter(row => row.verdict !== 'Avoid').sort((a, b) => order[a.verdict] - order[b.verdict]
733
+ return rows.filter(row => scoreEligible(row)).sort((a, b) => compareScores(a.score, b.score)
734
+ || order[a.verdict] - order[b.verdict]
683
735
  || Number(!pickOption(a)) - Number(!pickOption(b))
684
736
  || (pickOption(a) && pickOption(b) ? comparePicks(pickOption(a), pickOption(b), { requested, eligible, budget }) : 0));
685
737
  }
@@ -701,9 +753,10 @@ function topChoices(rows, requested, eligible, budget) {
701
753
  function packTriage(rows, sources, compact, endings, eligible, requested = [], budget) {
702
754
  const prices = {};
703
755
  const top = topChoices(rows, requested, eligible, budget);
704
- // Handle states for the top names: taken, not_found (no public profile found) or check (check yourself).
756
+ // Compact lists of platforms with taken, missing and unknown handles.
705
757
  const handles = Object.fromEntries(rows.filter(row => row._social).map(row => [row.name, row._social]));
706
- const names = rows.map(({ _free, _recommendable, _pick, _mark, _googleExplained, _receiptEndings, _handles, _social, _waiting, ...row }) => {
758
+ const names = rows.map(({ _free, _recommendable, _pick, _mark, _googleExplained, _receiptEndings, _handles, _social, _waiting, _score, _scoreInput,
759
+ ...row }) => {
707
760
  const own = {};
708
761
  for (const option of _free) {
709
762
  const entry = priceEntry(option);
@@ -724,10 +777,13 @@ function packTriage(rows, sources, compact, endings, eligible, requested = [], b
724
777
  if (size() > limit) for (const row of names) row.buy = null;
725
778
  }
726
779
  for (const trim of [
727
- // Platforms not listed under taken or not_found are "check yourself"; the results page lists them all.
780
+ // The results page retains every platform, including unknowns.
728
781
  () => { for (const value of Object.values(result.handles ?? {})) delete value.check; },
729
782
  // GitHub and npm stand in the handle states and the same-name summary too.
783
+ // The results page and say read the full score from the receipt; the machine field keeps value and band.
784
+ row => { if (row.score) { delete row.score.reasons; delete row.score.notChecked; } },
730
785
  row => { if (row.details) delete row.details.presence; },
786
+ row => { delete row.score; },
731
787
  row => { row.details = null; },
732
788
  row => { row.buy = null; },
733
789
  row => { if (row.traction) delete row.traction.geo; },
@@ -0,0 +1,18 @@
1
+ const channelsEndpoint = 'https://www.googleapis.com/youtube/v3/channels';
2
+
3
+ export const validYouTubeHandle = handle => handle.length >= 3 && handle.length <= 30;
4
+
5
+ export function youtubeHandleUrl(handle) {
6
+ return channelsEndpoint + '?' + new URLSearchParams({ part: 'id', forHandle: '@' + handle });
7
+ }
8
+
9
+ export function classifyYouTubeHandle(status, data) {
10
+ const errors = data?.error?.errors;
11
+ if (status === 404 && Array.isArray(errors) && errors.some(error => error?.reason === 'channelNotFound')) {
12
+ return 'not-found';
13
+ }
14
+ if (status !== 200 || !Array.isArray(data?.items) || data.error) return 'unknown';
15
+ if (data.items.length === 0) return 'not-found';
16
+ const id = data.items[0]?.id;
17
+ return data.items.length === 1 && typeof id === 'string' && /^UC[A-Za-z0-9_-]{22}$/.test(id) ? 'taken' : 'unknown';
18
+ }
package/display.mjs CHANGED
@@ -5,6 +5,7 @@ import { canRecommend, choosePick, comparePicks, eligibilityNeed, lowestTotal, l
5
5
  import { purchaseLine } from './clis/domain-check/naming-method.mjs';
6
6
 
7
7
  export { purchaseLine, showAsIs } from './clis/domain-check/naming-method.mjs';
8
+ import { compareScores } from './clis/domain-check/name-score.mjs';
8
9
  export const neverBuys = 'This check leaves checkout to you; open the link to buy.';
9
10
  export const attribution = 'via domainhound.dev';
10
11
 
@@ -181,11 +182,11 @@ function exactDisplay(result) {
181
182
  }
182
183
  const free = row.free?.find(option => option.d === ending);
183
184
  if (free?.s === 'prem') {
184
- if (notEligible) return ['**' + name + ' is free at the registry.** ' + notEligible + '.' + checked, ...tail].join('\n');
185
+ if (notEligible) return ['**' + name + ' is available at the registry.** ' + notEligible + '.' + checked, ...tail].join('\n');
185
186
  const shop = free.shop ?? Object.keys(result.buyUrlTemplate ?? {})[0];
186
187
  const link = templateLink(result.buyUrlTemplate, shop, domain);
187
- const head = free.risk ? '**' + name + ' is free at the registry.** May be premium, price at shop'
188
- : '**' + name + ' is free at the registry, but premium.** Premium, price at shop';
188
+ const head = free.risk ? '**' + name + ' is available at the registry.** May be premium, price at shop'
189
+ : '**' + name + ' is available at the registry, but premium.** Premium, price at shop';
189
190
  return [head + (link ? ': ' + link : '') + '.' + (free.risk ? ' No list price shown.' : ' No list price applies.') + checked,
190
191
  ...eligibility, ...tail].join('\n');
191
192
  }
@@ -202,9 +203,9 @@ function exactDisplay(result) {
202
203
  const ratio = jumpRatio(offer);
203
204
  const checkout = notEligible ?? (link ? link + (shop ? ' at ' + md(shop) : '') : '—');
204
205
  const lines = [
205
- '**' + name + (free.prem ? ' is free, at a premium price.** ' : ' is free.** ')
206
+ '**' + name + (free.prem ? ' is available, at a premium price.** ' : ' is available.** ')
206
207
  + (confirmed ? 'Price ' + priceLabel(free, shop) + '.'
207
- : 'The registry shows it free; the price is a list price' + (offer.now != null && date ? ' from ' + date : '')
208
+ : 'The registry shows it available; the price is a list price' + (offer.now != null && date ? ' from ' + date : '')
208
209
  + ', not a shop quote.') + checked,
209
210
  '',
210
211
  '| Domain | Today | Renewal | 3 years | Checkout |',
@@ -234,7 +235,7 @@ function exactDisplay(result) {
234
235
  const date = listDate(result);
235
236
  const hasEstimate = estimate?.now != null && date && !premiumRisk(domain);
236
237
  // DNS is a likelihood only; the registry or the shop settles it.
237
- const likely = row.likely_free?.includes(ending) ? ' Likely free (DNS), confirm at shop.'
238
+ const likely = row.likely_free?.includes(ending) ? ' Possibly available (DNS), confirm at shop.'
238
239
  : row.likely_taken?.includes(ending) ? ' Likely taken (DNS).' : '';
239
240
  const risk = premiumRisk(domain) ? ' A short name ' + mayBePremium + '.' : '';
240
241
  return ['**' + name + ': not settled.** The registry did not settle it' + (why ? ' (' + md(why) + ')' : '') + '.' + likely
@@ -327,7 +328,7 @@ export function checkDisplay(result, level = 0, purchase = false, preferred = []
327
328
  ? groupRows(rows, row => freeLines(row, listPrices, level, eligible))
328
329
  .flatMap(group => [group.names.join(', ') + ':', ...group.lines])
329
330
  : rows.flatMap(row => freeLines(row, listPrices, level, eligible));
330
- lines.push('', '**Free domains, one ending per line**' + (free.length ? '' : ': none found'), ...free, '');
331
+ lines.push('', '**Available domains, one ending per line**' + (free.length ? '' : ': none found'), ...free, '');
331
332
  const endingsOf = (row, key) => (row[key] ?? []).map(d => d.includes('.') ? d : '.' + d);
332
333
  const statusLines = project => level >= 3
333
334
  ? groupRows(rows, project).map(group => group.names.join(', ') + ' ' + group.lines.join(' '))
@@ -343,7 +344,7 @@ export function checkDisplay(result, level = 0, purchase = false, preferred = []
343
344
  if (taken.length) lines.push('Taken: ' + taken.join(' · '));
344
345
  // DNS is a likelihood only; the registry or the shop settles these.
345
346
  if (likelyTaken.length) lines.push('Likely taken (DNS): ' + likelyTaken.join(' · '));
346
- if (likelyFree.length) lines.push('Likely free (DNS), confirm at shop: ' + likelyFree.join(' · '));
347
+ if (likelyFree.length) lines.push('Possibly available (DNS), confirm at shop: ' + likelyFree.join(' · '));
347
348
  if (check.length) lines.push('Check at shop: ' + check.join(' · '));
348
349
  const reasons = new Map();
349
350
  for (const [ending, reason] of Object.entries(result.shopCheckWhy ?? {})) {
@@ -389,8 +390,9 @@ function rowBestValue(row, prices) {
389
390
  export function checkLines(row, short = false) {
390
391
  const original = typeof row?.name === 'string' ? row.name : '';
391
392
  const input = original.length > 100 ? label(original) : original;
392
- return nameCheckLines({ ...row, name: input }).map(({ label, text, link }) => {
393
+ return nameCheckLines({ ...row, name: input }).map(({ label, text, link, linkLabel }) => {
393
394
  const safe = isSearchLink(link, input);
395
+ if (linkLabel) return md(text) + (safe ? ' · [' + linkLabel + '](' + link + ')' : '');
394
396
  if (short && safe) return '[' + label + '](' + link + '): ' + md(text);
395
397
  return label + ': ' + md(text) + (safe ? ' · [search](' + link + ')' : '');
396
398
  });
@@ -427,7 +429,7 @@ export function topPicks(result, preferred = []) {
427
429
  const context = { requested: preferred, eligible: result.eligible ?? [] };
428
430
  const rest = rows.map((row, index) => ({ row, index, pick: eligiblePick(row, prices, result.eligible, preferred) }))
429
431
  .filter(({ row }) => !picks.some(pick => pick.name === row.name))
430
- .sort((a, b) => (verdictRank[a.row.verdict] ?? 3) - (verdictRank[b.row.verdict] ?? 3)
432
+ .sort((a, b) => compareScores(a.row.score, b.row.score) || (verdictRank[a.row.verdict] ?? 3) - (verdictRank[b.row.verdict] ?? 3)
431
433
  || Number(!a.pick) - Number(!b.pick) || (a.pick && b.pick ? comparePicks(a.pick, b.pick, context) : 0) || a.index - b.index);
432
434
  for (const { row, pick } of rest.slice(0, 3 - picks.length)) {
433
435
  picks.push({ name: row.name, verdict: row.verdict, reason: row.reason,
@@ -445,7 +447,7 @@ function nameLabel(name) {
445
447
  function topLines(result, showReason, showValue = true, preferred = []) {
446
448
  return ['**Top picks**', ...topPicks(result, preferred).map(row => {
447
449
  const ending = row.domain ? shown(row.domain) : row.ending && '.' + row.ending;
448
- const domain = ending ? ', pick ' + priced(ending, row) : ', no eligible free ending';
450
+ const domain = ending ? ', pick ' + priced(ending, row) : ', no eligible available ending';
449
451
  const value = !showValue ? '' : typeof row.bestValue === 'string'
450
452
  ? rowBestValue(result.names.find(candidate => candidate.name === row.name), result.prices)
451
453
  : row.bestValue && bestValueLine(row.bestValue.domain, row.bestValue);
@@ -483,7 +485,7 @@ export function triageDisplay(result, prior, { short = false, compact = false, p
483
485
  '**Name screen** (USD ex. VAT; list prices, the shop shows the final price; 2y = each payment covers two years)');
484
486
  if (result.eligibility) lines.push(eligibilityLine(result));
485
487
  const checkoutHeading = prior ? 'Cheapest eligible / checkout' : 'Checkout';
486
- lines.push('', '| Name | Verdict and reason | Free endings, one per line, today/renewal | ' + checkoutHeading + ' | Search checks |',
488
+ lines.push('', '| Name | Verdict and reason | Available endings, one per line, today/renewal | ' + checkoutHeading + ' | Search checks |',
487
489
  '|---|---|---|---|---|');
488
490
  for (const row of rows) {
489
491
  const base = label(row.name);
@@ -517,7 +519,7 @@ export function triageDisplay(result, prior, { short = false, compact = false, p
517
519
  shop_check: row.shop_check?.filter(ending => !likely.has(ending)),
518
520
  };
519
521
  for (const [key, heading] of [['premium', premiumRisk(base) ? mayBePremium : 'premium, price at shop'], ['taken', 'taken'],
520
- ['likely_taken', 'likely taken (DNS)'], ['likely_free', 'likely free (DNS), confirm at shop'], ['shop_check', 'check at shop']]) {
522
+ ['likely_taken', 'likely taken (DNS)'], ['likely_free', 'possibly available (DNS), confirm at shop'], ['shop_check', 'check at shop']]) {
521
523
  if (groups[key]?.length) cell.push(heading + ': ' + preferredFirst(groups[key], preferred).map(ending => '.' + ending).join(' '));
522
524
  }
523
525
  if (!compact && recheck.length) cell.push('earlier price, recheck: ' + recheck.map(previous).join(', '));
@@ -528,8 +530,10 @@ export function triageDisplay(result, prior, { short = false, compact = false, p
528
530
  const value = !compact && rowBestValue(row, prices);
529
531
  const reason = compact ? shorten(String(row.reason ?? '').split(' · ', 1)[0], 80) : row.reason;
530
532
  const checks = compact ? checkLines(row, false).map(line => line.split(' · [search]', 1)[0]) : checkLines(row, short);
531
- lines.push('| ' + nameLabel(row.name) + ' | ' + md(row.verdict) + ': ' + md(reason) + (compact ? '' : tractionLine(row, Boolean(prior) || short)) + ' | '
532
- + (cell.join('<br>') || 'none free') + (value ? '<br>' + value : '') + ' | ' + checkout + ' | '
533
+ const score = Number.isInteger(row.score?.value) ? ' · Name score ' + row.score.value + '/100, ' + row.score.band
534
+ : row.score?.filtered ? ' · Not scored: ' + row.score.filtered : '';
535
+ lines.push('| ' + nameLabel(row.name) + ' | ' + md(row.verdict) + ': ' + md(reason) + md(score) + (compact ? '' : tractionLine(row, Boolean(prior) || short)) + ' | '
536
+ + (cell.join('<br>') || 'none available') + (value ? '<br>' + value : '') + ' | ' + checkout + ' | '
533
537
  + checks.join('<br>') + ' |');
534
538
  }
535
539
  lines.push('', 'Choose a favorite and ask for its exact quote.');
@@ -605,7 +609,7 @@ export function progressText(progress, { rows = [], elapsedMs = 0, budgetMs = 0,
605
609
  '**Still checking** after ' + seconds(elapsedMs) + ' (answer budget ' + seconds(budgetMs) + '). The lookup keeps running.',
606
610
  'Registry answers so far: ' + (total - waiting) + ' of ' + total + ' domains.',
607
611
  ...names.map(row => '- ' + md(row.name) + ': ' + [
608
- ['free', row._groups.free], ['taken', row._groups.taken], ['premium', row._groups.premium],
612
+ ['available', row._groups.free], ['taken', row._groups.taken], ['premium', row._groups.premium],
609
613
  ['not settled', row._groups.shop_check], ['still checking', row._groups.checking],
610
614
  ].filter(([, endings]) => endings.length).map(([kind, endings]) => kind + ' ' + show(row, endings)).join(' · ')
611
615
  + (row._groups.checking.length ? ', ask again' : '')),
@@ -660,7 +664,7 @@ export function checkText(result, shortlist = false, { purchase = false, preferr
660
664
  for (const row of data.names) {
661
665
  const free = (row.free ?? []).map(option => '.' + option.d
662
666
  + (option.risk ? ' (may be premium)' : option.s === 'prem' || option.prem ? ' (premium)' : ''));
663
- const statuses = ['Free ' + (free.join(' ') || 'none found')];
667
+ const statuses = ['Available ' + (free.join(' ') || 'none found')];
664
668
  for (const [key, heading] of [['taken', 'taken'], ['resale', 'resale'], ['shop_check', 'check at shop']]) {
665
669
  if (row[key]?.length) statuses.push(heading + ' ' + row[key].map(ending => '.' + ending).join(' '));
666
670
  }
package/dossier.mjs CHANGED
@@ -5,7 +5,7 @@ import { dnsNeed } from './clis/domain-check/prices.mjs';
5
5
  export const dossierTool = {
6
6
  name: 'taken_domain_dossier',
7
7
  description: 'Investigate a taken domain: registry, site and public listing evidence, likely owner type, and a price range when supported, '
8
- + 'plus up to three free alternatives with upfront, renewal and three-year prices and a quick trademark, app and rival screen. '
8
+ + 'plus up to three available alternatives with upfront, renewal and three-year prices and a quick trademark, app and rival screen. '
9
9
  + 'Relay the display and sources. Keep maxBudget private and send no drafts. Share follow-up drafts and start a watch only on request.',
10
10
  annotations: { title: 'Taken domain dossier', readOnlyHint: true, destructiveHint: false, openWorldHint: true },
11
11
  inputSchema: {