domain-hound 0.1.3 → 0.1.5

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,4 +1,5 @@
1
1
  import { anySignal, cacheDir, readCache, writeCache } from './cache.mjs';
2
+ import { checkSocialHandles, handlePlatforms } from './handles.mjs';
2
3
 
3
4
  const uspto = 'https://tmsearch.uspto.gov';
4
5
  const githubState = 'triage-github-limit.json';
@@ -22,13 +23,8 @@ export const trademarkSearches = {
22
23
  WIPO: 'https://branddb.wipo.int/',
23
24
  Norway: 'https://search.patentstyret.no/',
24
25
  };
25
- export const handleSearches = {
26
- GitHub: 'https://github.com/{name}',
27
- npm: 'https://www.npmjs.com/package/{name}',
28
- PyPI: 'https://pypi.org/project/{name}/',
29
- X: 'https://x.com/{name}',
30
- YouTube: 'https://www.youtube.com/@{name}',
31
- };
26
+ // Handle pages in display order, with {name} for the handle.
27
+ export const handleSearches = Object.fromEntries(handlePlatforms.map(platform => [platform.id, platform.link('{name}')]));
32
28
 
33
29
  // Latin letters for name matching: accents drop, and letters without a decomposition fold too (ø -> o, æ -> ae).
34
30
  const folds = [[/æ/g, 'ae'], [/ø/g, 'o'], [/œ/g, 'oe'], [/ß/g, 'ss'], [/[đð]/g, 'd'], [/þ/g, 'th'], [/ł/g, 'l'], [/ı/g, 'i']];
@@ -225,13 +221,6 @@ async function fetchEntities(name, input, options) {
225
221
  });
226
222
  }
227
223
 
228
- const handleUrls = {
229
- npm: name => 'https://registry.npmjs.org/' + name,
230
- PyPI: name => 'https://pypi.org/simple/' + name + '/',
231
- X: name => 'https://x.com/' + name,
232
- YouTube: name => 'https://www.youtube.com/@' + name,
233
- };
234
-
235
224
  async function searchGitHub(name, options) {
236
225
  const { directory = cacheDir, now = new Date() } = options;
237
226
  try {
@@ -269,16 +258,8 @@ async function searchGitHub(name, options) {
269
258
  } catch { return { status: 'unknown' }; }
270
259
  }
271
260
 
272
- async function checkHandle(service, name, options) {
273
- try {
274
- if (options.signal?.aborted) return 'unknown';
275
- const response = await request(handleUrls[service](name), options, { redirect: 'manual', timeout: 2200 });
276
- await response.body?.cancel();
277
- if (response.status === 404) return 'free';
278
- return response.status === 200 ? 'taken' : 'unknown';
279
- } catch { return 'unknown'; }
280
- }
281
-
261
+ // Same-name evidence from GitHub and npm: the account or package (GitHub users API, npm registry) and, for small
262
+ // screens, GitHub repositories with the name. options.social may carry this name's handle rows from a shared run.
282
263
  export async function checkHandles(name, options = {}) {
283
264
  const { directory = cacheDir, now = new Date() } = options;
284
265
  const filename = 'triage-handles-' + name + '.json';
@@ -287,22 +268,11 @@ export async function checkHandles(name, options = {}) {
287
268
  const age = now.getTime() - entry?.at;
288
269
  return age >= 0 && age < day;
289
270
  };
271
+ const social = options.social ? await options.social
272
+ : (await checkSocialHandles([{ name, platforms: ['GitHub', 'npm'], links: false }], options)).get(name);
273
+ const state = platform => social?.find(entry => entry.platform === platform)?.state ?? 'check';
290
274
  const getGitHub = async () => {
291
- let status = saved.githubProfile?.status;
292
- if (!fresh(saved.githubProfile) || !['free', 'taken'].includes(status)) {
293
- const profile = async () => {
294
- try {
295
- const response = await request(handleSearches.GitHub.replace('{name}', name), options, {
296
- redirect: 'manual', timeout: 2200,
297
- });
298
- await response.body?.cancel();
299
- return response.status === 200 ? 'taken' : response.status === 404 ? 'free' : 'unknown';
300
- } catch { return 'unknown'; }
301
- };
302
- status = await profile();
303
- if (status === 'unknown' && options.retryUnavailable && !options.signal?.aborted) status = await profile();
304
- if (status !== 'unknown') saved.githubProfile = { status, at: now.getTime() };
305
- }
275
+ const status = state('GitHub');
306
276
  if (fresh(saved.githubSearch) && saved.githubSearch.result?.count !== undefined) {
307
277
  return { ...saved.githubSearch.result, status };
308
278
  }
@@ -311,18 +281,9 @@ export async function checkHandles(name, options = {}) {
311
281
  githubTail = turn.catch(() => {});
312
282
  const result = await turn;
313
283
  if (result.count !== undefined) saved.githubSearch = { result, at: now.getTime() };
314
- return { ...result, status: status === 'unknown' && result.status === 'taken' ? 'taken' : status };
284
+ return { ...result, status: status === 'check' && result.status === 'taken' ? 'taken' : status };
315
285
  };
316
- const [github, found] = await Promise.all([getGitHub(), Promise.all(Object.keys(handleUrls).map(async service => {
317
- const entry = saved[service];
318
- if (fresh(entry) && ['taken', 'free'].includes(entry.status)) return [service, entry.status];
319
- let status = await checkHandle(service, name, options);
320
- if (options.retryUnavailable && status === 'unknown' && !options.signal?.aborted) {
321
- status = await checkHandle(service, name, options);
322
- }
323
- if (status === 'taken' || status === 'free') saved[service] = { status, at: now.getTime() };
324
- return [service, status];
325
- }))]);
326
- await writeCache(directory, filename, saved).catch(() => {});
327
- return { github, handles: { GitHub: github.status, ...Object.fromEntries(found) } };
286
+ const github = await getGitHub();
287
+ await writeCache(directory, filename, { githubSearch: saved.githubSearch }).catch(() => {});
288
+ return { github, handles: { GitHub: github.status, npm: state('npm') }, social };
328
289
  }
@@ -4,6 +4,7 @@ import { shopSearchUrl } from './prices.mjs';
4
4
  import { checkHandles, compactText, handleSearches, letters, searchApps, searchEntities, searchMarks, trademarkSearches } from './triage-sources.mjs';
5
5
  import { loadEdgarCompanies, matchEdgarCompanies, searchNorwegianCompanies } from './company-search.mjs';
6
6
  import { mapLimit } from './cache.mjs';
7
+ import { checkSocialHandles } from './handles.mjs';
7
8
  import { checkDomainSite } from './com-site.mjs';
8
9
  import { playSearchLink, searchAndroidApps } from './google-play.mjs';
9
10
  import { googleSearchLink, lowerVerdict, nameCheckLines, searchGoogle } from './google-search.mjs';
@@ -11,6 +12,11 @@ import { autocompleteWords, collectRivals, createTraction, evidenceLifetime, jud
11
12
  tractionNotes, tractionSummary, tractionVerdict } from './traction.mjs';
12
13
 
13
14
  const coreWebsiteEndings = ['com', 'ai', 'io', 'app', 'co'];
15
+ // The slow, rate-limited sources (trademarks, app stores, rivals, web traction, GitHub and npm) screen only the first
16
+ // five names; registry answers and prices cover every name. Social handle rows go to the top three.
17
+ export const screenLimit = 5;
18
+ export const handleLimit = 3;
19
+ export const notScreened = 'Not screened (marks, apps, rivals: first ' + screenLimit + ' names only)';
14
20
  const typicalProducts = [
15
21
  [/(?:domain|whois)/, /\b(?:domains?|whois|registrar)\b/i],
16
22
  [/(?:accounting|bookkeep|invoice|ledger)/, /\b(?:accounting|bookkeeping|invoic(?:e|ing)|ledger)\b/i],
@@ -90,7 +96,7 @@ function counted(count, singular, plural = singular + 's') {
90
96
  return count + ' ' + (count === 1 ? singular : plural);
91
97
  }
92
98
 
93
- function sameNameEvidence({ name, live, norway, us, entities, entity, github, handles }) {
99
+ function sameNameEvidence({ name, live, norway, us, entities, entity, github, handles, deferHandles }) {
94
100
  const sameBusiness = live.filter(site => site.sameBusiness).length;
95
101
  const businesses = new Map();
96
102
  for (const { business } of live) if (business !== 'unknown') businesses.set(business, (businesses.get(business) ?? 0) + 1);
@@ -106,14 +112,13 @@ function sameNameEvidence({ name, live, norway, us, entities, entity, github, ha
106
112
  github.ownerType === 'Organization' && 'GitHub org taken',
107
113
  repos && counted(repos, 'GitHub repo'),
108
114
  handles.npm === 'taken' && 'npm package',
109
- handles.PyPI === 'taken' && 'PyPI package',
110
115
  ].filter(Boolean);
111
116
  const count = live.length + (norway?.matches.length ?? 0) + (us?.matches.length ?? 0) + (entities?.length ?? 0)
112
117
  + Math.min(repos * 0.25, 1) + Number(github.ownerType === 'Organization')
113
- + Number(handles.npm === 'taken') + Number(handles.PyPI === 'taken');
118
+ + Number(handles.npm === 'taken');
114
119
  const unchecked = [
115
- !norway && 'Brønnøysund', !us && 'EDGAR', !entities && 'Wikidata', github.status === 'unknown' && 'GitHub',
116
- handles.npm === 'unknown' && 'npm', handles.PyPI === 'unknown' && 'PyPI',
120
+ !norway && 'Brønnøysund', !us && 'EDGAR', !entities && 'Wikidata', !deferHandles && github.status === 'check' && 'GitHub',
121
+ !deferHandles && handles.npm === 'check' && 'npm',
117
122
  ].filter(Boolean);
118
123
  return {
119
124
  summary: 'Same name used by: ' + (summary.join(', ') || 'none found'),
@@ -151,8 +156,8 @@ function verdict({ mark, otherMark, silent, ...evidence }) {
151
156
  function silentSources({ marks, apps, android, entities, norway, edgar, github, handles }) {
152
157
  return Object.entries({
153
158
  USPTO: marks, 'App Store': apps, 'Google Play': android, Wikidata: entities, Brønnøysund: norway,
154
- EDGAR: edgar, GitHub: github.status === 'unknown' ? null : github.status,
155
- npm: handles.npm === 'unknown' ? null : handles.npm, PyPI: handles.PyPI === 'unknown' ? null : handles.PyPI,
159
+ EDGAR: edgar, GitHub: github.status === 'check' ? null : github.status,
160
+ npm: handles.npm === 'check' ? null : handles.npm,
156
161
  }).filter(([, value]) => value == null).map(([source]) => source);
157
162
  }
158
163
 
@@ -217,12 +222,14 @@ export async function namePresence(input, options = {}) {
217
222
  // Same-name rivals with measured traction follow the traction rules first; evidence whose traction could not be
218
223
  // measured keeps the earlier same-name checks. Trademark and availability guardrails stay in place.
219
224
  function baseVerdict({ rival, overlap, sameName, activeApp, brand, app, entity, mark, site, best, available, marks, apps, android,
220
- androidAnswered = android, com, premium = [] }) {
225
+ androidAnswered = android, company, premium = [] }) {
221
226
  if (rival?.[0] === 'Avoid') return rival;
222
227
  if (overlap) return ['Avoid', overlap.domain + ' is a live business in the same category'];
223
228
  if (activeApp) return ['Avoid', activeApp.name + ' is an app in the same category with ' + activeApp.ratings + ' ' + activeApp.store + ' ratings'];
224
229
  if (mark?.relevant && mark.tier !== 'Fuzzy') return ['Avoid', trademarkReason(mark)];
225
230
  if (rival) return rival;
231
+ if (company) return ['Check first', company.name + ' is an active same-name company' +
232
+ (company.employees > 0 ? ' with ' + company.employees + ' employees' : '')];
226
233
  if (brand) return ['Check first', brand.name + ' is an existing company or product in Wikidata'];
227
234
  if (mark) return ['Check first', trademarkReason(mark)];
228
235
  if (sameName.level !== 'few') return ['Check first', 'Several public sources show same-name use'];
@@ -231,12 +238,11 @@ function baseVerdict({ rival, overlap, sameName, activeApp, brand, app, entity,
231
238
  if (site) return ['Check first', site.domain + ' has a live site under this name'];
232
239
  if (entity) return ['Check first', 'An exact-name Wikidata entity already exists'];
233
240
  if (!marks || !apps || !androidAnswered || sameName.unchecked?.length) return ['Check first', 'A competition source did not answer'];
234
- if (com?.status === 'check-at-shop') return ['Check first', 'The .com registry status is unresolved'];
235
241
  if (!best) {
236
242
  return ['Check first', available.length ? 'The free endings require buyer eligibility'
237
243
  : premium.length ? 'The free endings may be premium, price at shop' : 'No domain was found free at the registry'];
238
244
  }
239
- return ['No conflict found', 'No close US mark, app or site overlap'];
245
+ return ['No conflict found', 'No US mark, same-name app or active company found in the sources checked'];
240
246
  }
241
247
 
242
248
  export async function triageNames(inputs, options = {}) {
@@ -261,7 +267,7 @@ export async function triageNames(inputs, options = {}) {
261
267
  const started = performance.now();
262
268
  const timeLeft = () => budgetMs - (performance.now() - started);
263
269
  const signal = AbortSignal.timeout(budgetMs);
264
- const sources = { ...options, signal, timeLeft, cacheLifetime: evidenceLifetime, retryUnavailable: true, githubSearch: names.size <= 5 };
270
+ const sources = { ...options, signal, timeLeft, cacheLifetime: evidenceLifetime, retryUnavailable: true, githubSearch: true };
265
271
  // Ask an unavailable source once more while the triage budget lasts.
266
272
  const retry = async (lookup, answered) => {
267
273
  const first = await lookup();
@@ -276,7 +282,7 @@ export async function triageNames(inputs, options = {}) {
276
282
  };
277
283
  const onSite = (domain, site) => {
278
284
  const name = domain.slice(0, domain.indexOf('.'));
279
- if (!nameOf.has(name)) return;
285
+ if (!nameOf.has(name) || nameOf.get(name) >= screenLimit) return;
280
286
  if (site?.state === 'live') startHomes(name, [domain]);
281
287
  else if (site?.state === 'parked' || site?.state === 'for-sale') startHomes(name, [domain], false);
282
288
  };
@@ -284,8 +290,12 @@ export async function triageNames(inputs, options = {}) {
284
290
  name, candidates: nameCandidates(name, { variants: false, endings: websiteEndings }),
285
291
  }));
286
292
  const entries = [...names].map(([name, input], index) => [keys.get(name), input, index]);
293
+ // The names put first are screened in full: the person's own name and the strongest candidates.
294
+ const screened = entries.slice(0, screenLimit);
295
+ const isScreened = index => index < screenLimit;
296
+ const screenedDomains = new Set([...names.keys()].slice(0, screenLimit));
287
297
  const check = (concurrency, lookup, after = () => {}) => mapLimit(entries, concurrency, async ([name, input, index]) => {
288
- const result = signal.aborted ? null : await retry(() => lookup(name, input, sources), found);
298
+ const result = signal.aborted || !isScreened(index) ? null : await retry(() => lookup(name, input, sources), found);
289
299
  after(result, index);
290
300
  return result;
291
301
  });
@@ -301,24 +311,37 @@ export async function triageNames(inputs, options = {}) {
301
311
  startHomes(name, (result ?? []).filter(row => row.brand).flatMap(row => (row.website ?? []).map(siteDomain))
302
312
  .filter(domain => domain?.split('.')[0].includes(name)));
303
313
  });
304
- const [domains, marksByName, appsByName, entitiesByName, handlesByName, norwayByName, androidApps, edgar, googleByName] =
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('.'))) });
317
+ // 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 });
320
+ // 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 => {
322
+ const order = handleOrder(domains.groups, keys, options.eligible).slice(0, handleLimit);
323
+ options.onProgress?.({ stage: 'handles' });
324
+ 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] =
305
327
  await Promise.all([
306
328
  // A cold cache still gets the bundled, dated list prices, so free endings never all read "price at shop".
307
- searchCandidates(groups, { ...options, budgetMs: Math.min(budgetMs, 11500),
308
- siteEndings: websiteEndings, siteTimeout: 3000, siteDetails: true, onSite }),
329
+ domainsDone,
309
330
  check(6, searchMarks), check(8, searchApps, (result, index) => startHomes(entries[index][0],
310
331
  (result ?? []).map(row => siteDomain(row.sellerUrl)).filter(domain => domain?.split('.')[0].includes(entries[index][0])))),
311
332
  entityChecks,
312
- Promise.all(entries.map(([name]) => checkHandles(name, sources))),
333
+ Promise.all(entries.map(([name], index) => isScreened(index)
334
+ ? checkHandles(name, { ...sources, social: evidenceHandles.then(rows => rows.get(name)).catch(() => null) }) : null)),
313
335
  check(8, searchNorwegianCompanies),
314
- searchAndroidApps(new Map(entries.map(([key, input]) => [key, input])),
336
+ searchAndroidApps(new Map(screened.map(([key, input]) => [key, input])),
315
337
  { ...sources, playBudgetMs: Math.min(12000, options.playBudgetMs ?? Infinity, budgetMs) }),
316
338
  retry(() => loadEdgarCompanies(sources), found),
317
- mapLimit(entries, 5, ([name, input, index]) => searchGoogle(name, input, {
339
+ mapLimit(entries, 5, ([name, input, index]) => isScreened(index) ? searchGoogle(name, input, {
318
340
  ...sources, timeoutMs: timeLeft(),
319
341
  entities: entities[index].promise,
320
342
  sameBusiness: text => describedBusiness(name, text, options.about, options.category),
321
- })),
343
+ }) : { unchecked: 'not screened' }),
344
+ handleRows,
322
345
  ]);
323
346
  const counts = {};
324
347
  function coverage(source, answered) { counts[source] = (counts[source] ?? 0) + Number(answered); }
@@ -328,6 +351,7 @@ export async function triageNames(inputs, options = {}) {
328
351
  ...(androidApps.get(keys.get(name)) ?? []).map(row => ({ ...row, store: 'Android', ref: row })),
329
352
  ]);
330
353
  const rivalsByName = domains.groups.map(({ name, sites }, index) => {
354
+ if (!isScreened(index)) return [];
331
355
  const raw = googleByName[index].raw ?? {};
332
356
  const key = keys.get(name);
333
357
  const rivals = collectRivals({
@@ -341,6 +365,40 @@ export async function triageNames(inputs, options = {}) {
341
365
  options.onProgress?.({ stage: 'rivals' });
342
366
  const evidence = await traction.settle();
343
367
  const rows = domains.groups.map(({ name, results, sites }, index) => {
368
+ const requested = results.filter(row => endings.includes(row.tld));
369
+ const available = results.filter(row => row.status === 'probably-free' && endings.includes(row.tld));
370
+ const recommendable = available.filter(row => canRecommend(row.tld, options.eligible));
371
+ const [best] = recommendable;
372
+ const social = socialByName.get(keys.get(name)) ?? null;
373
+ const domainFields = {
374
+ taken: requested.filter(row => row.status === 'taken').map(row => row.tld),
375
+ shop_check: requested.filter(row => ['check-at-shop', 'reserved'].includes(row.status)).map(row => row.tld),
376
+ ...(requested.some(row => row.status === 'reserved') && {
377
+ reserved: requested.filter(row => row.status === 'reserved').map(row => row.tld) }),
378
+ // Subsets of shop_check with a DNS likelihood; only a registry or shop settles them.
379
+ ...likelyEndings(requested),
380
+ // Premium endings never carry a list price; the shop shows their price. A short name may be premium.
381
+ ...(requested.some(row => row.status === 'premium') && {
382
+ premium: requested.filter(row => row.status === 'premium').map(row => row.tld) }),
383
+ };
384
+ const receipt = options.receipt && { _receiptEndings: requested.map(row => ({ domain: row.domain, source: row.source,
385
+ 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 };
387
+ if (!isScreened(index)) {
388
+ // Registry answers and prices only. The verdict never reads "No conflict found" without the checks.
389
+ return {
390
+ name: names.get(name), verdict: 'Check first', reason: notScreened,
391
+ _free: available, _recommendable: recommendable, _googleExplained: true,
392
+ google: { result: 'not checked', why: 'not screened', link: googleSearchLink(names.get(name)) },
393
+ ...domainFields,
394
+ competition: { US: null, mark: null, AppStore: null, GooglePlay: null, Wikidata: null,
395
+ sameName: { summary: 'Not screened', level: 'unknown' } },
396
+ buy: best ? best.buyUrl ?? shopSearchUrl(best.confirmShop, best.domain) : null,
397
+ ...receipt,
398
+ details: { memorable: memorability(keys.get(name), names.get(name)), presence: null, sites: {},
399
+ appName: 'App name: not checked', AndroidSearch: playSearchLink(names.get(name)) },
400
+ };
401
+ }
344
402
  const marks = marksByName[index];
345
403
  const apps = appsByName[index];
346
404
  const entities = entitiesByName[index];
@@ -362,9 +420,6 @@ export async function triageNames(inputs, options = {}) {
362
420
  const mark = marks?.[0];
363
421
  const others = marks?.filter(item => letters(item.name) !== letters(mark?.name)) ?? [];
364
422
  const otherMark = others.find(item => item.relevant) ?? others.find(item => item.tier === 'Fuzzy') ?? others[0];
365
- const available = results.filter(row => row.status === 'probably-free' && endings.includes(row.tld));
366
- const recommendable = available.filter(row => canRecommend(row.tld, options.eligible));
367
- const [best] = recommendable;
368
423
  const seen = websiteEndings.flatMap(tld => {
369
424
  const row = results.find(result => result.tld === tld);
370
425
  return tld === 'com' || row?.status === 'taken' ? [[tld, siteEvidence(row, sites[tld])]] : [];
@@ -383,23 +438,26 @@ export async function triageNames(inputs, options = {}) {
383
438
  const site = unmeasured[0];
384
439
  const overlap = unmeasured.find(row => row.sameBusiness && /\.(com|ai)$/.test(row.domain));
385
440
  const us = matchEdgarCompanies(key, edgar);
386
- const sameName = sameNameEvidence({ name: key, live, norway, us, entities, entity, github, handles });
441
+ const company = norway?.matches.find(row => row.employees > 0 && row.match === 'exact')
442
+ ?? us?.matches.find(row => row.match === 'exact');
443
+ const sameName = sameNameEvidence({ name: key, live, norway, us, entities, entity, github, handles, deferHandles: options.deferHandles });
387
444
  const otherEntities = entities?.filter(row => !explained.has(row));
388
- const legacy = sameNameEvidence({ name: key, live: unmeasured, norway, us, entities: otherEntities, entity, github, handles });
389
- const silent = silentSources({ marks, apps, android, entities, norway, edgar, github, handles });
445
+ 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));
390
448
  const otherEntity = otherEntities?.find(row => row.brand) ?? otherEntities?.[0];
391
449
  const [decision, reason] = verdict({
392
450
  rival: tractionVerdict(judged), overlap, sameName: legacy, activeApp,
393
451
  brand: otherEntity?.brand ? otherEntity : undefined, app: apps?.find(row => !explained.has(row)), entity: otherEntity,
394
452
  mark, otherMark, site, silent, best, available, marks, apps, premium: results.filter(row => row.status === 'premium'),
395
- android: android?.filter(row => !explained.has(row)), androidAnswered: android, com: results.find(row => row.tld === 'com'),
453
+ android: android?.filter(row => !explained.has(row)), androidAnswered: android, company,
396
454
  });
397
455
  const googleExplained = explainedGoogle(key, googleByName[index].raw, judged, entities);
398
456
  const summary = tractionSummary(judged);
399
457
  const answered = {
400
458
  USPTO: marks, 'App Store': apps, 'Google Play': android, Google: google.google, Wikidata: entities,
401
459
  Brønnøysund: norway, EDGAR: edgar,
402
- ...Object.fromEntries(Object.entries(handles).map(([service, status]) => [service, status === 'unknown' ? null : status])),
460
+ ...!options.deferHandles && Object.fromEntries(Object.entries(handles).map(([service, status]) => [service, status === 'check' ? null : status])),
403
461
  };
404
462
  for (const [source, value] of Object.entries(answered)) coverage(source, value != null);
405
463
  const competition = {
@@ -411,26 +469,21 @@ export async function triageNames(inputs, options = {}) {
411
469
  ...(entity.brand && { brand: true }) } : entities ? [] : null,
412
470
  sameName,
413
471
  };
414
- const requested = results.filter(row => endings.includes(row.tld));
415
472
  return {
416
473
  // Small and dormant same-name uses are notes after the reason; they never change the verdict.
417
474
  name: names.get(name), verdict: decision, reason: [reason, ...tractionNotes(judged)].join(' · '),
418
475
  _free: available, _recommendable: recommendable, _mark: mark, _googleExplained: googleExplained,
419
476
  ...(summary && { traction: summary }),
420
477
  google: { ...(google.google ?? { result: 'not checked', why: google.unchecked }), link: googleSearchLink(names.get(name)) },
421
- taken: requested.filter(row => row.status === 'taken').map(row => row.tld),
422
- shop_check: requested.filter(row => ['check-at-shop', 'reserved'].includes(row.status)).map(row => row.tld),
423
- // Subsets of shop_check with a DNS likelihood; only a registry or shop settles them.
424
- ...likelyEndings(requested),
425
- // Premium endings never carry a list price; the shop shows their price. A short name may be premium.
426
- ...(requested.some(row => row.status === 'premium') && {
427
- premium: requested.filter(row => row.status === 'premium').map(row => row.tld) }),
478
+ ...domainFields,
479
+ _social: compactHandles(social),
428
480
  // The checkout is the listed shop's search, or the confirming shop's search when no list price is known.
429
481
  competition, buy: best ? best.buyUrl ?? shopSearchUrl(best.confirmShop, best.domain) : null,
482
+ ...receipt,
430
483
  details: {
431
484
  memorable: memorability(key, names.get(name)),
432
485
  presence: Object.fromEntries(Object.entries(handles).map(([service, status]) =>
433
- [service, status === 'unknown' ? null : status])),
486
+ [service, status === 'check' ? null : status])),
434
487
  sites: Object.fromEntries(seen), appName: appStatus(apps, android),
435
488
  AndroidSearch: android ? null : playSearchLink(names.get(name)),
436
489
  },
@@ -444,8 +497,40 @@ export async function triageNames(inputs, options = {}) {
444
497
  }
445
498
  for (const row of googleCandidates(rows)) row.google.search = true;
446
499
  const sourcesSummary = Object.fromEntries(Object.entries(counts).map(([source, answered]) =>
447
- [source, Math.round(100 * answered / names.size)]));
448
- return packTriage(rows, sourcesSummary, options.compact, endings, options.eligible);
500
+ [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);
504
+ if (options.receipt) {
505
+ result.checkedAt = (options.now ?? new Date()).toISOString();
506
+ result.priceListDate = domains.priceDate?.slice(0, 10);
507
+ result.receiptDetails = receiptDetails;
508
+ if (options.deferHandles) {
509
+ const targets = handleOrder(domains.groups, keys, options.eligible).slice(0, handleLimit);
510
+ result.handleTargets = targets.map(name => ({ name, index: [...keys.values()].indexOf(name) }));
511
+ }
512
+ }
513
+ return result;
514
+ }
515
+
516
+ // The order the handle rows go in: the person's own name first, then names with a free recommendable ending,
517
+ // cheapest first, then the other screened names in input order.
518
+ export function handleOrder(groups, keys, eligible) {
519
+ const screened = groups.slice(0, screenLimit).map((group, index) => {
520
+ const free = group.results.filter(row => row.status === 'probably-free' && canRecommend(row.tld, eligible))
521
+ .map(row => row.firstPayment ?? Infinity);
522
+ return { key: keys.get(group.name), index, free: free.length > 0, cost: Math.min(...free, Infinity) };
523
+ });
524
+ const [first, ...rest] = screened;
525
+ rest.sort((a, b) => Number(b.free) - Number(a.free) || a.cost - b.cost || a.index - b.index);
526
+ return [first, ...rest].filter(Boolean).map(row => row.key);
527
+ }
528
+
529
+ function compactHandles(entries) {
530
+ if (!Array.isArray(entries)) return null;
531
+ const by = state => entries.filter(entry => entry.state === state).map(entry => entry.platform);
532
+ const [taken, notFound, check] = [by('taken'), by('not-found'), by('check')];
533
+ return { ...(taken.length && { taken }), ...(notFound.length && { not_found: notFound }), ...(check.length && { check }) };
449
534
  }
450
535
 
451
536
  // The first three ranked names, filled from the screened names in input order when fewer than three rank.
@@ -502,7 +587,9 @@ function topChoices(rows) {
502
587
  function packTriage(rows, sources, compact, endings, eligible) {
503
588
  const prices = {};
504
589
  const top = topChoices(rows);
505
- const names = rows.map(({ _free, _recommendable, _mark, _googleExplained, ...row }) => {
590
+ // Handle states for the top names: taken, not_found (no public profile found) or check (check yourself).
591
+ 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 }) => {
506
593
  const own = {};
507
594
  for (const option of _free) {
508
595
  const entry = priceEntry(option);
@@ -513,6 +600,7 @@ function packTriage(rows, sources, compact, endings, eligible) {
513
600
  return { ...row, free: _free.map(option => option.tld), own, bestValue: bestValue(_recommendable)?.tld ?? null };
514
601
  });
515
602
  const result = { top, names, prices, sources, eligibility: eligibilityNotes(endings),
603
+ ...(Object.keys(handles).length && { handles }),
516
604
  ...(eligible?.length && { eligible }),
517
605
  ...(!compact && names.length <= 5 && { trademarkSearches, handleSearches }) };
518
606
  const limit = names.length <= 5 ? (compact ? 5600 : 5999) : compact ? 9150 : 9850;
@@ -522,6 +610,10 @@ function packTriage(rows, sources, compact, endings, eligible) {
522
610
  if (size() > limit) for (const row of names) row.buy = null;
523
611
  }
524
612
  for (const trim of [
613
+ // Platforms not listed under taken or not_found are "check yourself"; the results page lists them all.
614
+ () => { for (const value of Object.values(result.handles ?? {})) delete value.check; },
615
+ // GitHub and npm stand in the handle states and the same-name summary too.
616
+ row => { if (row.details) delete row.details.presence; },
525
617
  row => { row.details = null; },
526
618
  row => { row.buy = null; },
527
619
  row => { if (row.traction) delete row.traction.geo; },
@@ -544,6 +636,8 @@ function packTriage(rows, sources, compact, endings, eligible) {
544
636
  if (typeof row.competition.US === 'string') row.competition.US = row.competition.US.split(':', 1)[0];
545
637
  row.reason = row.reason.split(' · ', 1)[0];
546
638
  },
639
+ // Last: the results page and say keep the full handle rows.
640
+ () => { delete result.handles; },
547
641
  ]) {
548
642
  if (size() <= limit) break;
549
643
  names.forEach(trim);
package/display.mjs CHANGED
@@ -28,7 +28,7 @@ const money = value => '$' + Number(value).toFixed(2);
28
28
  // The DNS label of a screened name: punycode for æøå, never with letters removed.
29
29
  const label = name => normalizeName(String(name ?? '')) ?? String(name ?? '').normalize('NFKD').toLowerCase().replace(/[^a-z0-9-]/g, '');
30
30
  const fullDomain = (name, d) => d.includes('.') ? d : name + '.' + d;
31
- const suffix = domain => domain.split('.').at(-1);
31
+ const suffix = domain => domain.endsWith('.co.uk') || domain === 'co.uk' ? 'co.uk' : domain.split('.').at(-1);
32
32
  const registered = (row, ending) => row.taken?.includes(ending) || row.resale?.includes(ending);
33
33
  const checkoutLimitation = 'Domain Hound cannot buy or complete checkout.';
34
34
  const mayBePremium = 'may be premium, price at shop';
@@ -157,7 +157,7 @@ function exactDisplay(result) {
157
157
  const row = result.names?.[0] ?? {};
158
158
  const domain = row.name;
159
159
  const name = shown(domain);
160
- const ending = domain.split('.').at(-1);
160
+ const ending = suffix(domain);
161
161
  const checked = result.checkedAt ? ' Checked ' + String(result.checkedAt).slice(0, 16).replace('T', ' ') + ' UTC.' : '';
162
162
  const others = otherEndingsLine(result);
163
163
  const tail = others ? [others] : [];
@@ -355,7 +355,7 @@ export function checkDisplay(result, level = 0, purchase = false) {
355
355
  } else if (rows.length === 1 || purchase) {
356
356
  const available = rows.flatMap(row => (row.free ?? []).flatMap(option => {
357
357
  const domain = option.d.includes('.') ? option.d : row.name.includes('.') ? row.name : row.name + '.' + option.d;
358
- if (!canRecommend(domain.split('.').at(-1), eligible)) return [];
358
+ if (!canRecommend(suffix(domain), eligible)) return [];
359
359
  const price = option.prem || option.s === 'prem' ? option : { ...listPrices[option.d], ...option };
360
360
  const link = templateLink(result.buyUrlTemplate, price.shop, domain);
361
361
  return link ? [{ link, price: price.now ?? Infinity }] : [];
@@ -526,8 +526,10 @@ function denseDisplay(result, short = false, links = true) {
526
526
  const names = results.map(row => '- **' + nameLabel(row.name) + '** — ' + md(row.verdict));
527
527
  const individual = names.map((name, index) => name + ' \n ' + checksFor(results[index]).join(' \n '));
528
528
  const groups = links ? [] : groupRows(results, checksFor);
529
+ // A long group names its first and last name, so twenty long labels do not repeat in every heading.
529
530
  const shared = groups.flatMap(({ names, lines }) => [
530
- names.length === results.length ? '**Search checks for every name**' : names.join(', '), ...lines,
531
+ names.length === results.length ? '**Search checks for every name**'
532
+ : names.length > 5 ? names.length + ' names, ' + names[0] + ' to ' + names.at(-1) : names.join(', '), ...lines,
531
533
  ]);
532
534
  const rows = shared.length && bytes([...names, ...shared].join('\n')) < bytes(individual.join('\n'))
533
535
  ? [...names, '', ...shared] : individual;
@@ -551,6 +553,7 @@ const progressStage = {
551
553
  quotes: 'Registry checks are in; shop prices are being checked.',
552
554
  browser: 'The live shop check is running.',
553
555
  rivals: 'Domain checks are in; trademark, app and rival checks are still running.',
556
+ handles: 'Domain checks are in; handles for the top three names are being checked.',
554
557
  };
555
558
 
556
559
  // The answer when a lookup outlasts this call's budget: what the registries have answered so far, the elapsed
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "domain-hound",
3
- "version": "0.1.3",
4
- "description": "Check domains, compare registrar prices, and screen product names from your MCP client.",
3
+ "version": "0.1.5",
4
+ "description": "Find a startup name and domain you can actually buy: availability, prices, app names, trademarks. MCP for Claude Code and Codex.",
5
5
  "license": "MIT",
6
6
  "type": "module",
7
7
  "bin": {
@@ -17,21 +17,37 @@
17
17
  },
18
18
  "keywords": [
19
19
  "mcp",
20
- "domains",
20
+ "mcp-server",
21
21
  "claude",
22
- "codex"
22
+ "claude-code",
23
+ "codex",
24
+ "domain",
25
+ "domain-availability",
26
+ "domain-name",
27
+ "startup-name",
28
+ "naming",
29
+ "trademark",
30
+ "app-name",
31
+ "whois",
32
+ "rdap",
33
+ "registrar",
34
+ "domain-prices"
23
35
  ],
24
36
  "mcpName": "dev.domainhound/domain-hound",
25
37
  "files": [
26
38
  "bin/domain-hound.mjs",
27
39
  "server.mjs",
28
40
  "display.mjs",
41
+ "results.mjs",
42
+ "results-style.mjs",
43
+ "watch.mjs",
29
44
  "clis/domain-check/cache.mjs",
30
45
  "clis/domain-check/com-site.mjs",
31
46
  "clis/domain-check/company-search.mjs",
32
47
  "clis/domain-check/confirm.mjs",
33
48
  "clis/domain-check/google-play.mjs",
34
49
  "clis/domain-check/google-search.mjs",
50
+ "clis/domain-check/handles.mjs",
35
51
  "clis/domain-check/index.mjs",
36
52
  "clis/domain-check/name-search.mjs",
37
53
  "clis/domain-check/naming-method.mjs",
@@ -54,7 +70,7 @@
54
70
  "server.json"
55
71
  ],
56
72
  "scripts": {
57
- "test": "node --test server.test.mjs clis/domain-check/*.test.mjs clis/domain-check/test.mjs",
73
+ "test": "node --test server.test.mjs results.test.mjs clis/domain-check/*.test.mjs clis/domain-check/test.mjs",
58
74
  "smoke": "node scripts/smoke.mjs",
59
75
  "snapshot-prices": "node scripts/snapshot-prices.mjs",
60
76
  "build-mcpb": "node scripts/build-mcpb.mjs"
package/plugin.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://agent-plugins.org/schemas/1.0.0/plugin.schema.json",
3
3
  "name": "domain-hound",
4
- "version": "0.1.3",
4
+ "version": "0.1.5",
5
5
  "description": "Check domain availability and prices, and screen product names, from your AI assistant.",
6
6
  "author": {
7
7
  "name": "Lars Hvinden"
@@ -13,7 +13,7 @@
13
13
  "interface": {
14
14
  "displayName": "Domain Hound",
15
15
  "shortDescription": "Domain prices and name checks",
16
- "longDescription": "Domain Hound is a local MCP server that helps you pick a product name and the best domain. It checks real registry availability, finds the cheapest trusted shop including the renewal price, and screens names for trademark conflicts, app store clashes and web traction. It has three tools: check_domains, triage_names and naming_method. It runs on your machine over stdio, needs no account, and is open source under the MIT license.",
16
+ "longDescription": "Domain Hound is a local MCP server that helps you pick a product name and the best domain. It checks real registry availability, finds the cheapest trusted shop including the renewal price, and screens names for trademark conflicts, app store clashes and web traction. It has four tools: check_domains, triage_names, naming_method and watch_domain. It runs on your machine over stdio, needs no account, and is open source under the MIT license.",
17
17
  "developerName": "Lars Hvinden",
18
18
  "category": "Developer Tools",
19
19
  "capabilities": [