domain-hound 0.1.2 → 0.1.4

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,7 +1,7 @@
1
1
  {
2
2
  "name": "domain-hound",
3
3
  "displayName": "Domain Hound",
4
- "version": "0.1.2",
4
+ "version": "0.1.4",
5
5
  "description": "Check domain availability and prices, and screen product names, from your AI assistant.",
6
6
  "author": {
7
7
  "name": "Lars Hvinden"
package/README.md CHANGED
@@ -44,10 +44,15 @@ For the optional browser fallback, run `npm install domain-hound playwright && n
44
44
  - `check_domains` checks one name or exact domain, or up to 20 at once. A bare name checks ten endings. The first lookup on a fresh install shows the list prices bundled with the package, labelled with their date, while the local price list refreshes in the background.
45
45
  - `triage_names` screens names against public domain, trademark, app, company, and handle data.
46
46
  - `naming_method` gives your assistant a recipe for generating and screening new names.
47
+ - `watch_domain` checks the registry, expiry and website. To start a free watch, give your assistant the email it should use. Confirm the watch in your inbox. Optional news requires a separate choice in that confirmation.
48
+
49
+ Completed lookups save an HTML page and a Markdown copy in `~/.domain-hound/results/`. The page lists prices, availability and sources for each ending checked. On macOS, naming and batch results open in the background. Windows and Wayland request a background open where the desktop supports it. Exact checks and watch results stay in chat with a file link. Set `DOMAIN_HOUND_OPEN=off` on the MCP server to keep every page closed.
47
50
 
48
51
  ## Privacy
49
52
 
50
- The server has no Domain Hound account or hosted backend. Lookups send the relevant name or domain to public sources. Domain searches use IANA and registry RDAP/WHOIS, public DNS, and public registrar pricing. When configured, the client sends selected domains to the Spaceship or Dynadot API for a quote. The optional browser check opens a registrar’s public search page. Name screening may also query the USPTO, Apple App Store, Google Play, Google Search and Trends, Wikidata, public company and package registries, social platforms, Tranco, Common Crawl, and candidate websites. If you configure a search provider via environment variables, queries can also go to Brave Search or Serper. Results may be cached locally.
53
+ Lookups need no Domain Hound account. They send the relevant name or domain to public sources. Domain searches use IANA and registry RDAP/WHOIS, public DNS, and public registrar pricing. When configured, the client sends selected domains to the Spaceship or Dynadot API for a quote. The optional browser check opens a registrar’s public search page. Name screening may also query the USPTO, Apple App Store, Google Play, Google Search and Trends, Wikidata, public company and package registries, social platforms, Tranco, Common Crawl, and candidate websites. If you configure a search provider via environment variables, queries can also go to Brave Search or Serper. Results may be cached locally.
54
+
55
+ Submitting a watch sends the domain, supplied email, optional name and news choice to the Domain Hound watch service. An agent’s yes highlights the news choice. The confirmation click records whether you want it. Result pages omit your supplied email and name.
51
56
 
52
57
  ## Daily checks
53
58
 
@@ -49,6 +49,7 @@ export async function searchNorwegianCompanies(name, input, options) {
49
49
  const match = companyMatch(letters(name), row.navn);
50
50
  if (match) matches.set(row.organisasjonsnummer, {
51
51
  name: compactText(row.navn, 65), match, url: 'https://virksomhet.brreg.no/nb/oppslag/enheter/' + row.organisasjonsnummer,
52
+ ...(Number.isSafeInteger(row.antallAnsatte) && row.antallAnsatte > 0 && { employees: row.antallAnsatte }),
52
53
  });
53
54
  }
54
55
  }
@@ -6,7 +6,8 @@ const budget = 20_500;
6
6
  const shopBudget = 10_000;
7
7
  const cacheLifetime = 15 * 60_000;
8
8
  const userAgent = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0 Safari/537.36';
9
- const dollars = String.raw`\$\s*(?:\d{1,3}(?:,\d{3})+|\d+)\.\d{2}`;
9
+ // Shops write whole-dollar prices without cents too ("$8" at Dynadot).
10
+ const dollars = String.raw`\$\s*(?:\d{1,3}(?:,\d{3})+|\d+)(?:\.\d{2})?`;
10
11
  const priceLine = new RegExp('^' + dollars + '$');
11
12
  const dynadotPrices = new RegExp('^(?:' + dollars + '){1,2}$');
12
13
  const lastPrice = new RegExp(dollars + '$');
@@ -16,7 +17,8 @@ const namecheapPrice = new RegExp('^(' + dollars + ')/yr$', 'i');
16
17
  const namecheapRenewal = new RegExp('^Renews at (' + dollars + ')/yr\\.?$', 'i');
17
18
  const cloudflareQuote = new RegExp('^Buy now: ([a-z0-9.-]+) for (' + dollars + ')\\. Renews at (' + dollars + ') per year\\.$', 'i');
18
19
  const taken = /^(?:Taken|Registered in \d{4})$/i;
19
- const premiumLabel = /^(?:Premium|Premium domain)$/i;
20
+ // "Premium", "Premium domain", and Dynadot's "Registry Premium" for a price the registry sets.
21
+ const premiumLabel = /^(?:Registry\s+)?Premium(?:\s+(?:domain|name))?$/i;
20
22
  const trackerRoots = [
21
23
  'google-analytics.com', 'googletagmanager.com', 'doubleclick.net', 'googlesyndication.com',
22
24
  'facebook.net', 'facebook.com', 'nr-data.net', 'newrelic.com', 'crazyegg.com',
@@ -3,9 +3,11 @@ import { setTimeout as delay } from 'node:timers/promises';
3
3
  import { pathToFileURL } from 'node:url';
4
4
  import { promisify } from 'node:util';
5
5
  import { apiShops, cachedSignals, confirmDomain, confirmingShops, lightConfirm } from './confirm.mjs';
6
+ import { checkDomainSite } from './com-site.mjs';
6
7
  import { appStoreSearchLink, googleSearchLink, nameCheckLines, playSearchLink } from './google-search.mjs';
7
- import { canRecommend, eligibilityNotes, mergeQuote, nameCandidates, normalizeName, pickName, rankName, registrationStatus,
8
- searchCandidates, searchName, termCosts, validEligibility, validEndings, withoutListPrice } from './name-search.mjs';
8
+ import { applyLiveSite, asciiDomain, canRecommend, defaultEndings, eligibilityNotes, listQuote, mergeQuote, nameCandidates, normalizeName, pickName,
9
+ premiumRisk, rankName, registrationStatus, searchCandidates, searchName, termCosts, unicodeName, validEligibility, validEndings,
10
+ withPremiumRisk, withoutListPrice } from './name-search.mjs';
9
11
  import { bundledCatalog, catalogOffers, datedListPrices, isListPriceUsable, loadCachedCatalog, refreshPrices } from './price-catalog.mjs';
10
12
  import { lookupRegistrations } from './registry.mjs';
11
13
  import { namingRecipe, purchaseLine } from './naming-method.mjs';
@@ -65,10 +67,12 @@ async function openShop(args) {
65
67
  }
66
68
 
67
69
  export function normalize(input) {
68
- const domain = typeof input === 'string' ? input.trim().toLowerCase()
70
+ const typed = typeof input === 'string' ? input.trim().toLowerCase()
69
71
  .replace(/^[a-z][a-z\d+.-]*:\/\//, '')
70
72
  .split(/[/?#]/, 1)[0]
71
73
  .replace(/^www\.(?=[^.]+\.)/, '') : '';
74
+ // A Unicode domain is checked as its punycode form, never with letters removed.
75
+ const domain = asciiDomain(typed) ?? '';
72
76
  const labels = domain.split('.');
73
77
  const label = /^[a-z\d](?:[a-z\d-]{0,61}[a-z\d])?$/;
74
78
  const tld = /^(?:[a-z]{2,63}|xn--[a-z\d](?:[a-z\d-]{0,57}[a-z\d])?)$/;
@@ -192,7 +196,9 @@ export async function checkDomain(input, {
192
196
  // Porkbun's own quote above its list price, without a premium flag, may still be premium.
193
197
  const porkbunList = pricing?.pricing?.[tld] ? catalogPrice(pricing.pricing[tld].registration) : null;
194
198
  const porkbunPremium = confirmed && (confirmed.premium || (porkbunList != null && confirmed.price > porkbunList + 0.01));
195
- const premium = registry.signal === 'premium' || shopQuote?.status === 'premium' || porkbunPremium;
199
+ // A short name may be premium: no list price unless a shop marks its quote as standard.
200
+ const risk = registry.status === 'free' && premiumRisk(domain) && shopQuote?.standard !== true && !porkbunPremium;
201
+ const premium = registry.signal === 'premium' || shopQuote?.status === 'premium' || porkbunPremium || risk;
196
202
  const reserved = registry.signal === 'reserved' || shopQuote?.status === 'reserved';
197
203
  const verdict = shopQuote?.status === 'taken' || registry.status === 'taken' ? 'taken'
198
204
  : reserved ? 'reserved' : premium ? 'premium' : confirmed || shopQuote?.status === 'confirmed' ? 'confirmed' : registry.status;
@@ -209,8 +215,9 @@ export async function checkDomain(input, {
209
215
  confirmed: confirmed ? { ...confirmed, ...(!confirmed.premium && { possible: true }) } : null,
210
216
  ...(shopQuote && { shopQuote }), best, cheapestToday: null, offers: best ? [best] : [], stale: false,
211
217
  priceDate: null, nok, vatNorway,
218
+ ...(risk && !quoted && { premiumRisk: true }),
212
219
  notes: [registry.reason, reserved ? 'Not offered for registration; check at the shop'
213
- : best ? null : 'Premium, price at shop'].filter(Boolean),
220
+ : best ? null : risk && !registry.signal ? 'May be premium, price at shop' : 'Premium, price at shop'].filter(Boolean),
214
221
  buyUrl: shopSearchUrl(shopId, domain),
215
222
  };
216
223
  }
@@ -282,6 +289,9 @@ const agentLegend = {
282
289
  y3: 'Payments due in three years, USD ex. VAT',
283
290
  term: 'Years per payment when more than one',
284
291
  jump: 'Renewal over twice the first annual price',
292
+ risk: 'Short name: may be premium, price at the shop',
293
+ likely_free: 'Registry silent, DNS has no delegation: likely free, confirm at a shop',
294
+ likely_taken: 'Registry silent, DNS has a delegation: likely taken',
285
295
  };
286
296
  const googleEndings = new Set(['app', 'dev']);
287
297
  // Playwright is optional. Without it (or its browser) the live shop check cannot run at all.
@@ -315,7 +325,8 @@ function agentPrice({ firstPayment: now, renewalPayment: renew, threeYear: y3, m
315
325
  // The shop quote time as HH:MM UTC.
316
326
  const quoteClock = value => typeof value === 'string' ? value.match(/T(\d{2}:\d{2})/)?.[1] ?? null : null;
317
327
 
318
- function compactAgentResult(groups, names, complete, checkedAt, batch, rateLimited = false, liveCheck = null) {
328
+ function compactAgentResult(groups, names, complete, checkedAt, batch, rateLimited = false, liveCheck = null,
329
+ { eligible, otherEndings } = {}) {
319
330
  const buyUrlTemplate = {};
320
331
  const shopCheckWhy = {};
321
332
  const listPrices = {};
@@ -324,7 +335,7 @@ function compactAgentResult(groups, names, complete, checkedAt, batch, rateLimit
324
335
  let priceListDate;
325
336
  let best;
326
337
  for (const { name, results } of groups) {
327
- const taken = [], resale = [], free = [], shop_check = [];
338
+ const taken = [], resale = [], free = [], shop_check = [], reserved = [], likelyFree = [], likelyTaken = [];
328
339
  for (const row of results) {
329
340
  checkedEndings.add(row.tld);
330
341
  const d = row.exact ? row.tld : row.domain;
@@ -332,11 +343,14 @@ function compactAgentResult(groups, names, complete, checkedAt, batch, rateLimit
332
343
  const premium = row.status === 'premium';
333
344
  const confirmed = row.status === 'confirmed' || (premium && row.price != null && row.source === 'shop');
334
345
  const price = agentPrice({ ...row, shop });
335
- if (batch && !confirmed && !premium && row.status !== 'reserved' && listPrices[d]?.now == null) {
346
+ // A taken exact domain can show a standard ending benchmark. For .ai this explains its two-year renewal.
347
+ const benchmark = !batch && row.exact && row.status === 'taken' && row.listPrice
348
+ && (row.tld === 'ai' || !premiumRisk(row.domain));
349
+ if ((batch || benchmark) && !confirmed && !premium && row.status !== 'reserved' && listPrices[d]?.now == null) {
336
350
  const listed = row.listPrice ? agentPrice(row.listPrice) : price;
337
351
  if (Object.keys(listed).length) listPrices[d] = listed;
338
352
  }
339
- const date = (row.priceCheckedAt ?? (batch ? row.listPrice?.checkedAt : null))?.slice(0, 10);
353
+ const date = (row.priceCheckedAt ?? (batch || benchmark ? row.listPrice?.checkedAt : null))?.slice(0, 10);
340
354
  // Use the oldest list date among the displayed estimates.
341
355
  if (date && (priceListDate === undefined || date < priceListDate)) priceListDate = date;
342
356
  if (row.status === 'taken') {
@@ -349,12 +363,13 @@ function compactAgentResult(groups, names, complete, checkedAt, batch, rateLimit
349
363
  buyUrlTemplate[shop] = url + '{domain}' + suffix;
350
364
  }
351
365
  if (premium && !confirmed) {
352
- // Premium without a price: free to register, but only the shop shows the price.
353
- free.push({ d, s: 'prem', ...(shop && { shop }) });
366
+ // Premium without a price: free to register, but only the shop shows the price. A short name may be premium.
367
+ free.push({ d, s: 'prem', ...(shop && { shop }), ...(row.premium === 'risk' && { risk: true }) });
354
368
  continue;
355
369
  }
356
370
  if (row.status === 'reserved') {
357
371
  shop_check.push(d);
372
+ reserved.push(d);
358
373
  shopCheckWhy[row.domain] = String(row.registryReason ?? 'Not offered for registration').slice(0, 80);
359
374
  continue;
360
375
  }
@@ -362,6 +377,8 @@ function compactAgentResult(groups, names, complete, checkedAt, batch, rateLimit
362
377
  if (!batch && row.status === 'check-at-shop' && price.now != null) listPrices[d] = price;
363
378
  shop_check.push(d);
364
379
  shopCheckWhy[d] ??= shopCheckReason(row, rateLimited);
380
+ if (row.likely === 'free') likelyFree.push(d);
381
+ if (row.likely === 'taken') likelyTaken.push(d);
365
382
  continue;
366
383
  }
367
384
  // A batch row repeats its ending's standard price only when it differs.
@@ -369,7 +386,7 @@ function compactAgentResult(groups, names, complete, checkedAt, batch, rateLimit
369
386
  const at = confirmed ? quoteClock(row.quotedAt ?? row.checkedAt) : null;
370
387
  free.push({ d, s: confirmed ? 'ok' : 'nc', ...(!standard && price), ...(premium && { prem: row.premium ?? true }),
371
388
  ...(at && { at }) });
372
- if (confirmed && !premium) {
389
+ if (confirmed && !premium && canRecommend(row.tld, eligible) && !premiumRisk(row.domain)) {
373
390
  const { now, renew, y3, term, jump } = price;
374
391
  const buyUrl = row.buyUrl ?? shopSearchUrl(shopId, row.domain);
375
392
  // The cheapest confirmed quote is the pick; rows are already sorted by first payment within a name.
@@ -381,8 +398,12 @@ function compactAgentResult(groups, names, complete, checkedAt, batch, rateLimit
381
398
  ...(shop && { shop }), ...(buyUrl && { buyUrl }) };
382
399
  }
383
400
  }
384
- byName.set(name, { name, ...(taken.length && { taken }), ...(resale.length && { resale }),
385
- ...(free.length && { free }), ...(shop_check.length && { shop_check }) });
401
+ const unicode = unicodeName(name);
402
+ byName.set(name, { name, ...(unicode && { unicode }), ...(taken.length && { taken }), ...(resale.length && { resale }),
403
+ ...(free.length && { free }), ...(shop_check.length && { shop_check }),
404
+ ...(reserved.length && { reserved }),
405
+ // Subsets of shop_check with a DNS likelihood; only a registry or shop settles them.
406
+ ...(likelyFree.length && { likely_free: likelyFree }), ...(likelyTaken.length && { likely_taken: likelyTaken }) });
386
407
  }
387
408
  const result = {
388
409
  ...(!batch && names[0].includes('.') && {
@@ -390,12 +411,14 @@ function compactAgentResult(groups, names, complete, checkedAt, batch, rateLimit
390
411
  }),
391
412
  complete, checkedAt, ...(priceListDate && { priceListDate }), ...(best && { best }),
392
413
  eligibility: eligibilityNotes([...checkedEndings]),
414
+ ...(eligible?.length && { eligible }),
393
415
  names: names.map(name => byName.get(name)),
394
416
  legend: agentLegend,
395
417
  ...(Object.keys(buyUrlTemplate).length && { buyUrlTemplate }),
396
418
  ...(Object.keys(shopCheckWhy).length && { shopCheckWhy }),
397
419
  // The registry and list-price evidence above stays; this only says the shop quote could not be checked.
398
420
  ...(liveCheck && !best && { liveCheck }),
421
+ ...(otherEndings && Object.keys(otherEndings).length && { otherEndings }),
399
422
  };
400
423
  if (Object.keys(listPrices).length) {
401
424
  result.listPrices = listPrices;
@@ -446,7 +469,8 @@ export async function agentResult(input, options = {}) {
446
469
  googleEndings.has(row.tld) && /HTTP 429/.test(row.registryReason ?? '')));
447
470
  if (batch) rateLimited = await retryGoogle(fast, remaining, options) || rateLimited;
448
471
  const rows = fast.groups.flatMap(group => group.results);
449
- const targets = domain ? rows.filter(row => ['probably-free', 'check-at-shop', 'premium'].includes(row.status))
472
+ const targets = domain ? rows.filter(row => canRecommend(row.tld, options.eligible)
473
+ && ['probably-free', 'check-at-shop', 'premium'].includes(row.status))
450
474
  : lightTargets(rows, options.eligible);
451
475
  const [candidate] = targets;
452
476
  // A Google retry can settle every row that the first pass left waiting.
@@ -490,10 +514,36 @@ export async function agentResult(input, options = {}) {
490
514
  complete = false;
491
515
  }
492
516
  const apply = row => quotes.has(row.domain) ? mergeQuote(row, quotes.get(row.domain)) : row;
493
- const rankedGroups = fast.groups.map(({ name, results }) => ({ name, results: rankName(results.map(apply)) }));
517
+ const rankedGroups = fast.groups.map(group => ({ ...group, results: rankName(group.results.map(apply)) }));
494
518
  const checkedAt = options.now?.toISOString() ?? new Date().toISOString();
495
- return compactAgentResult(rankedGroups, names, complete, checkedAt, batch, rateLimited,
496
- options.browser ? liveCheckFor(candidate, quote) : null);
519
+ // An exact .com gets the standard list prices of the other endings as one benchmark line, with no extra lookups.
520
+ const exactCom = names.length === 1 && names[0].endsWith('.com') ? names[0] : null;
521
+ const otherEndings = exactCom ? await endingBenchmarks(exactCom, options) : null;
522
+ const result = compactAgentResult(rankedGroups, names, complete, checkedAt, batch, rateLimited,
523
+ options.browser ? liveCheckFor(candidate, quote) : null, { eligible: options.eligible, otherEndings });
524
+ if (options.receipt) result.receiptDetails = rankedGroups.map(({ results, sites }) => ({ endings: results.map(row => ({
525
+ domain: row.domain, source: row.source, checkedAt: row.checkedAt, priceAt: row.priceCheckedAt,
526
+ shop: row.shop, checkout: row.buyUrl, site: sites?.[row.tld], risk: row.premium === 'risk' || row.premiumRisk,
527
+ })) }));
528
+ return result;
529
+ }
530
+
531
+ // The cheapest standard list price of each other ending for this label, from the saved or bundled price list.
532
+ // A short label may be premium, so it gets no benchmark.
533
+ async function endingBenchmarks(domain, options) {
534
+ const label = domain.slice(0, domain.indexOf('.'));
535
+ if (premiumRisk(label)) return null;
536
+ const now = options.now ?? new Date();
537
+ const bundled = options.bundledCatalog === undefined ? bundledCatalog : options.bundledCatalog;
538
+ const catalog = await loadCachedCatalog(options.directory).catch(() => null);
539
+ const prices = {};
540
+ for (const tld of defaultEndings.filter(ending => ending !== 'com' && canRecommend(ending, options.eligible))) {
541
+ const quote = listQuote(catalog, { domain: label + '.' + tld, tld }, now, bundled);
542
+ if (quote.price == null) continue;
543
+ const costs = termCosts(tld, quote.price, quote.renewal);
544
+ prices[tld] = agentPrice({ ...costs, renewalJump: quote.renewal > 2 * quote.price, shop: quote.shop });
545
+ }
546
+ return prices;
497
547
  }
498
548
 
499
549
  // Give unresolved .app and .dev rows one bounded registry retry with the batch time that is left.
@@ -509,14 +559,29 @@ async function retryGoogle(fast, remaining, options) {
509
559
  const until = performance.now() + budget;
510
560
  const timeLeft = () => Math.max(0, Math.floor(until - performance.now()));
511
561
  const answers = new Map();
562
+ const siteChecks = [];
563
+ const sites = new Map();
564
+ const verify = options.verifyFreeSite ?? options.comSite ?? checkDomainSite;
565
+ const checkNegative = options.fetcher === undefined || options.verifyFreeSite;
512
566
  let timer;
513
567
  await Promise.race([
514
568
  lookupRegistrations([...pending.values()].map(({ domain, tld, exact }) => ({ domain, tld, exact })), {
515
569
  directory: options.directory, fetcher: options.fetcher, pause: options.pause, now: options.now,
516
570
  // DNS already showed no name servers for these rows.
517
571
  resolveNs: async () => [], timeLeft, rdapAttempts: 1,
518
- onResult: (candidate, registry) => { if (timeLeft() > 0) answers.set(candidate.domain, registry); },
519
- }).catch(() => {}),
572
+ onResult: ({ domain }, registry) => {
573
+ if (!timeLeft()) return;
574
+ if (registry.status !== 'free' || !checkNegative) {
575
+ answers.set(domain, registry);
576
+ return;
577
+ }
578
+ const wait = Math.min(1_200, timeLeft());
579
+ siteChecks.push(Promise.resolve().then(() => verify(domain, wait, true)).then(site => {
580
+ sites.set(domain, site);
581
+ answers.set(domain, applyLiveSite(registry, site));
582
+ }, () => { answers.set(domain, registry); }));
583
+ },
584
+ }).then(() => Promise.all(siteChecks)).catch(() => {}),
520
585
  new Promise(resolve => { timer = setTimeout(resolve, budget + 100); }),
521
586
  ]);
522
587
  clearTimeout(timer);
@@ -525,16 +590,18 @@ async function retryGoogle(fast, remaining, options) {
525
590
  group.results = rankName(group.results.map(row => {
526
591
  const answer = pending.has(row.domain) && answers.get(row.domain);
527
592
  if (!answer) return row;
593
+ if (sites.has(row.domain)) group.sites[row.tld] = sites.get(row.domain);
528
594
  const status = registrationStatus(answer);
529
595
  if (status === 'check-at-shop') {
530
596
  if (/HTTP 429/.test(answer.reason ?? '')) limited = true;
531
- return { ...row, registryReason: answer.reason ?? row.registryReason };
597
+ return { ...row, registryReason: answer.reason ?? row.registryReason, ...(answer.likely && { likely: answer.likely }) };
532
598
  }
533
- const settled = { ...row, status, source: answer.source, registryReason: undefined, forSale: Boolean(answer.forSale),
599
+ const { likely, ...open } = row;
600
+ const settled = { ...open, status, source: answer.source, registryReason: undefined, forSale: Boolean(answer.forSale),
534
601
  checkedAt: answer.checkedAt ?? (options.now ?? new Date()).toISOString() };
535
602
  if (status === 'premium') return { ...withoutListPrice(settled, status), premium: true };
536
603
  if (status === 'reserved') return withoutListPrice(settled, status, answer.reason);
537
- if (status !== 'taken') return settled;
604
+ if (status !== 'taken') return withPremiumRisk(settled);
538
605
  const { price, renewal, shop, priceCheckedAt } = row;
539
606
  for (const key of ['price', 'renewal', 'shop', 'priceSource', 'priceCheckedAt', 'buyUrl']) delete settled[key];
540
607
  return price == null ? settled : { ...settled, listPrice: { shop, checkedAt: priceCheckedAt,
@@ -586,6 +653,7 @@ function lookupArgs(args) {
586
653
  else if (arg === '--eligible' && !options.eligible) options.eligible = (args[++index] ?? '').split(',');
587
654
  else if (arg === '--category' && !options.category) options.category = (args[++index] ?? '').slice(0, 100);
588
655
  else if (arg === '--compact') options.compact = true;
656
+ else if (arg === '--receipt') options.receipt = true;
589
657
  // The headless browser shop check runs only on this explicit flag.
590
658
  else if (arg === '--confirm') options.browser = true;
591
659
  else if (arg === '--geo' && options.geo === undefined) options.geo = readGeo(args[++index]);
@@ -1,8 +1,10 @@
1
+ import { domainToASCII, domainToUnicode } from 'node:url';
1
2
  import { checkDomainSite } from './com-site.mjs';
2
3
  import { cachedSignals, confirmingShops } from './confirm.mjs';
3
4
  import { bundledCatalog, datedListPrices, getNameCatalog, loadCachedCatalog, targetEndings } from './price-catalog.mjs';
4
5
  import { linkable, shopSearchUrl } from './prices.mjs';
5
6
  import { lookupRegistrations } from './registry.mjs';
7
+ import { foldLatin } from './triage-sources.mjs';
6
8
 
7
9
  const checked = '2026-11-23';
8
10
  const facts = {
@@ -11,6 +13,7 @@ const facts = {
11
13
  source: 'https://www.namecheap.com/domains/registration/cctld/ai/', checked,
12
14
  },
13
15
  no: {
16
+ need: 'Norwegian org/ID',
14
17
  note: 'Norwegian address plus organization number or personal ID required',
15
18
  eligibility: 'Norwegian organization or eligible individual, with a Norwegian postal address',
16
19
  source: 'https://www.norid.no/en/om-domenenavn/regelverk-for-no/', checked,
@@ -43,6 +46,11 @@ export function canRecommend(tld, eligible = []) {
43
46
  return !facts[tld]?.eligibility || eligible.includes(tld);
44
47
  }
45
48
 
49
+ // What a buyer needs for a restricted ending, in a few words: "Norwegian org/ID".
50
+ export function eligibilityNeed(tld) {
51
+ return facts[tld]?.eligibility ? facts[tld].need ?? 'eligibility' : null;
52
+ }
53
+
46
54
  export function eligibilityNotes(endings) {
47
55
  const notes = Object.fromEntries(restrictedEndings.filter(tld => endings.includes(tld))
48
56
  .map(tld => [tld, facts[tld].note]));
@@ -54,16 +62,65 @@ export function validEndings(endings) {
54
62
  && endings.every(ending => targetEndings.includes(ending));
55
63
  }
56
64
 
65
+ // One DNS label for a name. Spaces and punctuation go; letters never do. A name with non-ASCII letters (æ, ø, å, é)
66
+ // becomes its punycode label (xn--...), the form registries and shops use for that exact spelling.
57
67
  export function normalizeName(input) {
58
68
  if (typeof input !== 'string' || /[./\\]/.test(input)) return null;
59
- const name = input.normalize('NFKD').toLowerCase().replace(/[^a-z0-9-]/g, '');
60
- return label.test(name) ? name : null;
69
+ const name = input.normalize('NFC').toLowerCase().replace(/[^\p{L}\p{N}\p{M}-]/gu, '');
70
+ if (/^[a-z0-9-]*$/.test(name)) return label.test(name) ? name : null;
71
+ const ascii = domainToASCII(name);
72
+ return label.test(ascii) ? ascii : null;
73
+ }
74
+
75
+ // An exact domain in its DNS form: a Unicode domain becomes its punycode form; anything else returns null.
76
+ export function asciiDomain(input) {
77
+ if (typeof input !== 'string') return null;
78
+ const value = input.normalize('NFC').toLowerCase();
79
+ if (!/^[\p{L}\p{N}\p{M}.-]+$/u.test(value)) return null;
80
+ return /^[\x00-\x7f]+$/.test(value) ? value : domainToASCII(value) || null;
81
+ }
82
+
83
+ // The Unicode spelling of an ASCII label or domain, or null when it has no punycode part.
84
+ export function unicodeName(value) {
85
+ if (typeof value !== 'string' || !/(?:^|\.)xn--/.test(value)) return null;
86
+ const shown = domainToUnicode(value);
87
+ return shown && shown !== value ? shown : null;
88
+ }
89
+
90
+ // A Latin-letter key for name matching in rival, app, mark and handle sources: Grønnstue -> gronnstue.
91
+ // ASCII names keep their DNS label as the key.
92
+ export function searchKey(input) {
93
+ const dns = normalizeName(input);
94
+ if (!dns?.startsWith('xn--')) return dns;
95
+ const key = foldLatin(input).replace(/[^a-z0-9-]/g, '');
96
+ return label.test(key) ? key : dns;
97
+ }
98
+
99
+ // Short labels (four characters or fewer, counted in Unicode) are often premium at the registry or the shop.
100
+ // Their list price is withheld until a shop quote settles it.
101
+ export const premiumRiskLength = 4;
102
+ export function premiumRisk(domain) {
103
+ const first = String(domain ?? '').split('.')[0];
104
+ if (!first) return false;
105
+ return [...(unicodeName(first) ?? first)].length <= premiumRiskLength;
106
+ }
107
+
108
+ // A free row for a short label: the registry says free, but the price may be premium. No list price stays on it.
109
+ export function withPremiumRisk(row) {
110
+ if (!row || row.status !== 'probably-free' || !premiumRisk(row.domain)) {
111
+ if (row?.status === 'check-at-shop' && premiumRisk(row.domain) && row.price != null) {
112
+ return { ...withoutListPrice(row, 'check-at-shop'), premiumRisk: true };
113
+ }
114
+ return row;
115
+ }
116
+ return { ...withoutListPrice(row, 'premium'), premium: 'risk' };
61
117
  }
62
118
 
63
119
  export function nameCandidates(name, { variants: includeVariants = true, endings = defaultEndings } = {}) {
64
120
  const selected = endings;
65
121
  const exact = [...new Set(selected)].map(tld => ({ domain: name + '.' + tld, tld, exact: true }));
66
- if (!includeVariants || !selected.includes('com')) return exact;
122
+ // A punycode label takes no prefix or suffix: "get" + "xn--..." is not that spelling.
123
+ if (!includeVariants || !selected.includes('com') || name.startsWith('xn--')) return exact;
67
124
  const variants = ['get' + name, 'try' + name, 'use' + name, name + 'hq'];
68
125
  return [...exact, ...variants.filter(value => label.test(value)).map(value => ({
69
126
  domain: value + '.com', tld: 'com', exact: false,
@@ -86,7 +143,7 @@ export function termCosts(tld, price, renewal) {
86
143
  export function rankName(rows) {
87
144
  return rows.map(row => {
88
145
  const { tld, exact, status, price = null, renewal = null } = row;
89
- const reason = status === 'premium' ? 'Premium price' : status === 'reserved' ? 'Not offered for registration'
146
+ const reason = status === 'premium' ? row.premium === 'risk' ? 'May be premium' : 'Premium price' : status === 'reserved' ? 'Not offered for registration'
90
147
  : status === 'taken' ? 'Already registered'
91
148
  : status === 'check-at-shop' ? 'Check at shop'
92
149
  : exact ? 'Exact name' : 'Name variation';
@@ -98,7 +155,7 @@ export function rankName(rows) {
98
155
 
99
156
  export function pickName(rows, eligible) {
100
157
  return rows.reduce((best, row) => {
101
- if (!canRecommend(row.tld, eligible) || !['probably-free', 'confirmed'].includes(row.status)) return best;
158
+ if (!canRecommend(row.tld, eligible) || premiumRisk(row.domain) || !['probably-free', 'confirmed'].includes(row.status)) return best;
102
159
  return !best || firstCost(row) < firstCost(best) ||
103
160
  (firstCost(row) === firstCost(best) && row.exact && !best.exact) ? row : best;
104
161
  }, undefined);
@@ -110,6 +167,11 @@ export function registrationStatus(registry) {
110
167
  return registry.status === 'taken' ? 'taken' : 'check-at-shop';
111
168
  }
112
169
 
170
+ export function applyLiveSite(registry, site) {
171
+ if (registry.status !== 'free' || !['live', 'parked', 'for-sale'].includes(site?.state)) return registry;
172
+ return { status: 'taken', source: 'web', checkedAt: registry.checkedAt, forSale: site.state === 'for-sale' };
173
+ }
174
+
113
175
  export function listQuote(catalog, { domain, tld }, now, bundled = bundledCatalog) {
114
176
  // Data-only shops never become the listed pick or its checkout link.
115
177
  const prices = datedListPrices(catalog, tld, now, bundled).filter(row => linkable(row.id)).sort((a, b) =>
@@ -150,8 +212,10 @@ export function mergeQuote(row, quote) {
150
212
  return { ...withoutListPrice(row, 'reserved', quote.reason ?? 'Not offered for registration'),
151
213
  checkedAt: quote.checkedAt ?? row.checkedAt };
152
214
  }
215
+ // A short name stays a possible premium unless the shop marks its quote as standard.
153
216
  const premium = row.status === 'premium' && row.premium === true ? true
154
- : quote.status === 'premium' ? quote.premium ?? true : possiblePremium(row, quote) ? 'possible' : false;
217
+ : quote.status === 'premium' ? quote.premium ?? true : possiblePremium(row, quote) ? 'possible'
218
+ : (row.premium === 'risk' || row.premiumRisk) && quote.standard !== true ? 'possible' : false;
155
219
  const price = money(quote.price) > 0 ? quote.price : null;
156
220
  return { ...row, status: premium ? 'premium' : quote.status, price, renewal: price == null ? null : quote.renewal ?? null,
157
221
  ...(premium && { premium }), shop: quote.shopName, buyUrl: quote.buyUrl, priceCheckedAt: null, priceSource: null,
@@ -169,19 +233,33 @@ export async function searchCandidates(groups, options = {}) {
169
233
  const sites = new Map();
170
234
  const siteEndings = options.siteEndings ?? (options.skipComSite ? [] : ['com']);
171
235
  const lookedUp = new Map();
236
+ const checks = [];
172
237
  let catalog = null;
173
238
  let timer;
174
239
  let complete = false;
175
240
  const onResult = ({ domain, tld, exact }, registry) => {
176
241
  if (timeLeft() <= 0) return;
177
- lookedUp.set(domain, registry);
178
- options.onProgress?.({ domain, status: registrationStatus(registry) });
179
- if (registry.status !== 'taken' || !exact || !siteEndings.includes(tld)) return;
242
+ const publish = (result) => {
243
+ lookedUp.set(domain, result);
244
+ const status = registrationStatus(result);
245
+ options.onProgress?.({ domain, status: status === 'probably-free' && premiumRisk(domain) ? 'premium' : status });
246
+ };
247
+ // A negative registry answer can be wrong. A real response on the domain beats a free claim.
248
+ // Replay and unit callers that inject registry traffic can inject the site check as well.
249
+ const checkNegative = registry.status === 'free' && (options.fetcher === undefined || options.verifyFreeSite);
250
+ const checkTaken = registry.status === 'taken' && exact && siteEndings.includes(tld);
251
+ if (!checkNegative) publish(registry);
252
+ if (!checkNegative && !checkTaken) return;
180
253
  const timeout = Math.min(options.siteTimeout ?? 1200, timeLeft());
181
- sites.set(domain, { pending: (options.comSite ?? checkDomainSite)(domain, timeout, options.siteDetails).then(site => {
254
+ const visit = checkNegative ? options.verifyFreeSite ?? options.comSite ?? checkDomainSite
255
+ : options.comSite ?? checkDomainSite;
256
+ const pending = Promise.resolve().then(() => visit(domain, timeout, options.siteDetails || checkNegative)).then(site => {
182
257
  sites.get(domain).result = site;
183
258
  options.onSite?.(domain, site);
184
- }).catch(() => {}) });
259
+ if (checkNegative) publish(applyLiveSite(registry, site));
260
+ }, () => { if (checkNegative) publish(registry); });
261
+ sites.set(domain, { pending });
262
+ checks.push(pending);
185
263
  };
186
264
  const loadCatalog = options.cachedOnly ? loadCachedCatalog(options.directory)
187
265
  : getNameCatalog({ ...options, now, coldWaitMs: bundled ? 0 : Math.min(1900, budgetMs) });
@@ -189,7 +267,7 @@ export async function searchCandidates(groups, options = {}) {
189
267
  lookupRegistrations([...candidates.values()], { ...options, now, timeLeft, onResult }),
190
268
  loadCatalog.then(value => { catalog = value; }),
191
269
  ]).then(async () => {
192
- await Promise.all([...sites.values()].map(site => site.pending));
270
+ await Promise.all(checks);
193
271
  complete = lookedUp.size === candidates.size;
194
272
  });
195
273
  try {
@@ -204,8 +282,8 @@ export async function searchCandidates(groups, options = {}) {
204
282
  const rows = rankName(group.candidates.map(row => {
205
283
  const lookup = lookedUp.get(row.domain);
206
284
  if (!lookup) {
207
- const waiting = { ...row, status: 'check-at-shop', registryReason: 'Registry lookup timed out',
208
- ...listQuote(catalog, row, now, bundled) };
285
+ const waiting = withPremiumRisk({ ...row, status: 'check-at-shop', registryReason: 'Registry lookup timed out',
286
+ ...listQuote(catalog, row, now, bundled) });
209
287
  const signal = signals.get(row.domain);
210
288
  return ['premium', 'reserved'].includes(signal?.status) ? mergeQuote(waiting, signal) : waiting;
211
289
  }
@@ -215,9 +293,10 @@ export async function searchCandidates(groups, options = {}) {
215
293
  ? { shop: quote.shop, checkedAt: quote.priceCheckedAt, ...termCosts(row.tld, quote.price, quote.renewal),
216
294
  renewalJump: quote.renewal > 2 * quote.price }
217
295
  : null;
218
- const settled = { ...row, status, checkedAt: lookup.checkedAt ?? checkedAt, source: lookup.source, registryReason: lookup.reason,
219
- forSale: Boolean(lookup.forSale), ...(lookup.marketplace && { marketplace: lookup.marketplace }),
220
- ...(status !== 'taken' ? quote : listPrice && { listPrice }) };
296
+ const settled = withPremiumRisk({ ...row, status, checkedAt: lookup.checkedAt ?? checkedAt, source: lookup.source,
297
+ registryReason: lookup.reason, forSale: Boolean(lookup.forSale), ...(lookup.marketplace && { marketplace: lookup.marketplace }),
298
+ ...(status === 'check-at-shop' && lookup.likely && { likely: lookup.likely }),
299
+ ...(status !== 'taken' ? quote : listPrice && { listPrice }) });
221
300
  if (status === 'premium') return { ...withoutListPrice(settled, 'premium'), premium: true };
222
301
  if (status === 'reserved') return withoutListPrice(settled, 'reserved', lookup.reason);
223
302
  const signal = status === 'taken' ? null : signals.get(row.domain);
@@ -15,7 +15,7 @@ export const geoInstruction = 'GEO (presence in AI answers): for each name, answ
15
15
  export const namingRecipe = (about = '') => 'Naming recipe (intermediate). Use the final triage display.\n'
16
16
  + (about ? '1. Brief: ' + about.replace(/[\p{Cc}\p{Cf}\p{Zl}\p{Zp}]+/gu, ' ').trim()
17
17
  + '.\n' : '1. Brief: product, audience and preferences.\n')
18
- + '2. Generate about 30 words. Pair one with a familiar animal or object. Avoid category-generic names.\n'
18
+ + '2. Generate about 30 words. Pair one with a familiar animal or object. Default to English unless the person asked for another language. Avoid category-generic names.\n'
19
19
  + '3. Check: call check_domains ONCE with seven bare names and shortlist: true (Quiet Otter → quietotter). No spaces or dots.\n'
20
- + '4. Triage: call triage_names ONCE on only the best FIVE with free endings, a short about and geo from memory. Follow its Google search instructions.\n'
21
- + '5. Answer: ' + showAsIs + ' Keep all five candidates and let the person choose.';
20
+ + '4. Triage: call triage_names ONCE on the best FIVE with free endings, a short about and geo from memory. Pass the same endings and budget to both calls.\n'
21
+ + '5. Answer: Relay say as written. Let the person choose from the complete local results page.';