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.
package/server.mjs CHANGED
@@ -12,6 +12,10 @@ import { watchDomain, watchTool } from './watch.mjs';
12
12
  import { domainDossier, dossierTool } from './dossier.mjs';
13
13
  import { myDomains, portfolioTool } from './clis/portfolio/portfolio.mjs';
14
14
  import { callPurchaseTool, purchaseToolNames, registeredTools, withCheckQuoteOffer, withWatchQuoteOffer } from './clis/spaceship/tools.mjs';
15
+ import { candidateFields, compactScore, compareScores, scoreEligible, scoreHandles, scoreName, validCandidate } from './clis/domain-check/name-score.mjs';
16
+ import { scoreLogger } from './clis/domain-check/score-log.mjs';
17
+ import { HostedRateLimit, hostedClient } from './hosted.mjs';
18
+ import { generatedChecks, hostedChecks, hostedResult } from './hosted-results.mjs';
15
19
 
16
20
  // The capability ships inside the package; tests inject another directory through serve({ cwd }).
17
21
  export const capabilityDir = fileURLToPath(new URL('./clis/domain-check/', import.meta.url));
@@ -35,7 +39,7 @@ const nameSchema = { type: 'string', minLength: 1, maxLength: 127, pattern: entr
35
39
  const endingsSchema = {
36
40
  type: 'array', minItems: 1, maxItems: supportedEndings.length, uniqueItems: true,
37
41
  items: { type: 'string', enum: supportedEndings },
38
- description: 'Endings to consider for the recommendation, in preference order; listed endings rank first. For .com only use ["com"]. The page still shows all twelve default endings for bare names. '
42
+ description: 'Endings to consider for the recommendation, in preference order; listed endings rank first. For .com only use ["com"]. The page still shows all ten default endings for bare names. '
39
43
  + 'On request only (add them here when the person asks or names a country): ' + requestEndings.map(ending => '.' + ending).join(', ') + '.',
40
44
  };
41
45
  const countryEnding = {
@@ -46,7 +50,7 @@ function regionalEnding(country) {
46
50
  const code = country?.toUpperCase();
47
51
  return Object.hasOwn(countryEnding, code) ? countryEnding[code] : europeanCountries.has(code) ? 'eu' : null;
48
52
  }
49
- const selectedEndings = args => [...new Set([...(args.endings ?? []), regionalEnding(args.country), ...defaultEndings].filter(Boolean))];
53
+ const selectedEndings = args => [...new Set([...(args.endings ?? []), ...(args.eligible ?? []), regionalEnding(args.country), ...defaultEndings].filter(Boolean))];
50
54
  const lookupProperties = {
51
55
  country: { type: 'string', pattern: '^[A-Za-z]{2}$', description: 'Buyer country code if supplied, such as SE, DK, DE or GB for .co.uk. Do not infer it from language alone.' },
52
56
  ai: { type: 'boolean', description: 'Legacy option. .ai is now included by default.' },
@@ -73,6 +77,7 @@ const checkTool = {
73
77
  description: '1 to 20 bare names, exact domains or both, e.g. ["lanternbay","quietbook","lanternbay.me"]. Use one DNS label for a bare name, with no spaces or dots. A dot means an exact domain. Supply either names or query.' },
74
78
  shortlist: { type: 'boolean', description: 'Legacy: true for a preliminary bare-name batch. The naming recipe now goes straight to triage_names.' },
75
79
  purchase: { type: 'boolean', description: 'Pass true when asked to buy or register, even for an exact domain that may be taken. State the checkout limitation from the display in the answer.' },
80
+ picked: { type: 'boolean', description: 'Pass true with an exact query only after the person explicitly chooses a name already shown. Used by the opt-in local score log.' },
76
81
  confirm: { type: 'boolean', description: 'True only when the person explicitly asks for a live shop check. Uses an optional headless browser and is slower.' },
77
82
  },
78
83
  additionalProperties: false,
@@ -85,12 +90,17 @@ const legacyTool = { ...checkTool, name: 'broker_find',
85
90
 
86
91
  const triageTool = {
87
92
  name: 'triage_names',
88
- description: 'Find or vet a product name before any other search. For naming, generate five distinct, easy-to-say names, with the supplied name first. '
89
- + 'Call triage_names once with those names, a short about description and shortlist: true. Checks domains, trademarks, apps, rivals and meanings. '
90
- + 'Use the returned verdicts and label unfinished checks as pending. ' + relay,
93
+ description: 'Find or vet a product name. Pass idea to use the website’s name generator, or pass names to check supplied candidates. '
94
+ + 'For a second round, pass the same idea with wanted, avoid and round. Use the returned verdicts and label unfinished checks as pending. ' + relay,
91
95
  inputSchema: {
92
96
  type: 'object',
93
97
  properties: {
98
+ idea: { type: 'string', minLength: 3, maxLength: 400, description: 'A short product idea. Use idea or names.' },
99
+ wanted: { type: 'array', maxItems: 5, items: { type: 'string', minLength: 1, maxLength: 40 },
100
+ description: 'Names the person liked in the previous round.' },
101
+ avoid: { type: 'array', maxItems: 5, items: { type: 'string', minLength: 1, maxLength: 40 },
102
+ description: 'Names the person rejected in the previous round.' },
103
+ round: { type: 'integer', minimum: 1, maximum: 20, description: 'Which naming round this is.' },
94
104
  ...lookupProperties,
95
105
  names: { type: 'array', minItems: 1, maxItems: 20, items: { type: 'string', minLength: 1, maxLength: 100 },
96
106
  description: '1 to 20 bare names without endings, e.g. ["Quiet Otter","Hush Room"].' },
@@ -99,21 +109,31 @@ const triageTool = {
99
109
  companyType: { type: 'string', enum: Object.keys(handlePriorities),
100
110
  description: 'Use developer, consumer, b2b or media when it fits, to highlight the handles that matter.' },
101
111
  additionalHandles: { type: 'array', uniqueItems: true, items: { type: 'string', enum: requestPlatforms.map(platform => platform.id) },
102
- description: 'Extra check links only when requested. Snapchat, Reddit, Twitch, Threads, Pinterest or Discord.' },
112
+ description: 'Extra check links only when requested. Snapchat, Reddit, Twitch, Pinterest or Discord. Threads is checked by default.' },
103
113
  category: { type: 'string', minLength: 1, maxLength: 100, description: 'Category for relevant trademark classes and competitors. Use travel, software, finance, retail, health, education, food or media.' },
104
114
  about: { type: 'string', minLength: 1, maxLength: 160, description: 'A short description of what your product does, to identify overlapping sites and apps.' },
115
+ candidates: { type: 'object', maxProperties: 20,
116
+ additionalProperties: { type: 'object', additionalProperties: false, properties: Object.fromEntries(Object.entries(candidateFields)
117
+ .map(([key, rule]) => [key, rule === 'boolean' ? { type: 'boolean' } : rule === 'integer' ? { type: 'integer', minimum: 1, maximum: 5 }
118
+ : { type: 'string', enum: rule }])) },
119
+ description: 'Naming evidence per name for the Name score, from your own judgment: recipe; relation to the subject (direct, loose, none); '
120
+ + 'spellings when heard (1 = one obvious spelling); realWord (contains a real word); descriptive (two subject words or subject + generic word); '
121
+ + 'misspelled; narrow (names one feature); soundsLike (none, competitor, drug, pokemon); badMeaning in 14 languages (none, mild, severe); '
122
+ + 'language (english, asked, other). Missing evidence counts as not checked and keeps the name out of Strong. '
123
+ + 'Example: {"Loomfox":{"recipe":"odd-pair","relation":"direct","spellings":1,"realWord":true,"descriptive":false,"misspelled":false,"narrow":false,"soundsLike":"none"}}.' },
105
124
  geo: { type: 'object', maxProperties: 20,
106
125
  additionalProperties: { type: 'string', minLength: 1, maxLength: 160, pattern: '^\\s*(?:[Kk]nown\\b.*\\S.*|[Uu]nknown)\\s*$' },
107
126
  description: geoInstruction + ' Example: {"ExampleBoard":"known: a team notes workspace","QuietOtter":"unknown"}.' },
108
127
  },
109
- required: ['names'],
128
+ oneOf: [{ required: ['names'] }, { required: ['idea'] }],
110
129
  additionalProperties: false,
111
130
  },
112
131
  };
113
132
 
114
133
  const namingTool = {
115
134
  name: 'naming_method',
116
- description: 'Read the naming recipe when the person asks for the method. To find or screen names directly, use triage_names.',
135
+ description: 'Read the naming method (process, recipes, bans, steering question and real names by type) before generating names, '
136
+ + 'or when the person asks for the method. To screen names, use triage_names.',
117
137
  inputSchema: { type: 'object', properties: {
118
138
  about: { type: 'string', minLength: 1, maxLength: 512, description: 'An optional one-sentence product description.' },
119
139
  }, additionalProperties: false },
@@ -205,6 +225,10 @@ function cliArguments(args) {
205
225
  if (Object.hasOwn(args, 'shortlist') && typeof args.shortlist !== 'boolean') {
206
226
  throw new Error('shortlist must be a boolean.');
207
227
  }
228
+ if (Object.hasOwn(args, 'picked') && (typeof args.picked !== 'boolean'
229
+ || (args.picked && (!hasQuery || typeof args.query !== 'string' || !args.query.includes('.'))))) {
230
+ throw new Error('picked must be a boolean and requires an exact domain query when true.');
231
+ }
208
232
  const names = hasQuery ? [] : batchNames(args.names);
209
233
  if (args.shortlist && (hasQuery || names.some(name => name.includes('.')))) {
210
234
  throw new Error('Use shortlist only with bare names in names.');
@@ -244,6 +268,17 @@ function geoValue(geo, names) {
244
268
  return Object.fromEntries(Object.entries(geo).map(([name, text]) => [name, text.trim()]));
245
269
  }
246
270
 
271
+ // Naming evidence per screened name; the keys must be names in the list, like geo.
272
+ function candidatesValue(candidates, names) {
273
+ const valid = isObject(candidates) && Object.keys(candidates).length <= 20
274
+ && Object.entries(candidates).every(([name, entry]) => name.length >= 1 && name.length <= 100 && validCandidate(entry));
275
+ if (!valid) throw new Error('candidates must map each name to naming evidence with the supported fields and values.');
276
+ const screened = new Set(names.map(normalizeName).filter(Boolean));
277
+ const extra = Object.keys(candidates).find(name => !screened.has(normalizeName(name)));
278
+ if (extra !== undefined) throw new Error('candidates names ' + showValue(extra) + ', which is not in names.');
279
+ return candidates;
280
+ }
281
+
247
282
  function triageArguments(args) {
248
283
  if (!isObject(args) || Object.keys(args).some(key => !Object.hasOwn(triageTool.inputSchema.properties, key))) {
249
284
  throw new Error('Supply an object with names and an optional about.');
@@ -251,6 +286,9 @@ function triageArguments(args) {
251
286
  if (!Array.isArray(args.names) || args.names.length < 1 || args.names.length > 20) {
252
287
  throw new Error('names must list 1 to 20 names' + (Array.isArray(args.names) ? '; it has ' + args.names.length : '') + '.');
253
288
  }
289
+ if (['idea', 'wanted', 'avoid', 'round'].some(key => Object.hasOwn(args, key))) {
290
+ throw new Error('Use wanted, avoid and round only with idea.');
291
+ }
254
292
  const bad = args.names.findIndex(name => typeof name !== 'string' || !name.trim() || name.length > 100 || /[,.\p{Cc}]/u.test(name));
255
293
  if (bad >= 0) {
256
294
  throw new Error('names[' + bad + '] is not valid. Supply 1 to 20 bare names of up to 100 characters, without commas or domain endings.');
@@ -280,9 +318,28 @@ function triageArguments(args) {
280
318
  flags.push('--about', args.about);
281
319
  }
282
320
  if (Object.hasOwn(args, 'geo')) flags.push('--geo', JSON.stringify(geoValue(args.geo, args.names)));
321
+ if (Object.hasOwn(args, 'candidates')) flags.push('--candidates', JSON.stringify(candidatesValue(args.candidates, args.names)));
283
322
  return ['--triage', args.names.join(','), '--compact', '--receipt', ...flags];
284
323
  }
285
324
 
325
+ function generationArguments(args) {
326
+ if (Object.keys(args).some(key => !['idea', 'wanted', 'avoid', 'round'].includes(key))) {
327
+ throw new Error('Supply idea and optional wanted, avoid and round.');
328
+ }
329
+ const { idea, wanted, avoid, round } = args;
330
+ if (typeof idea !== 'string' || idea.trim().length < 3 || idea.length > 400 || !/\p{L}/u.test(idea) || /[\p{Cc}\p{Cf}]/u.test(idea)) {
331
+ throw new Error('Give a product idea between 3 and 400 characters.');
332
+ }
333
+ for (const value of [wanted, avoid]) {
334
+ if (value !== undefined && (!Array.isArray(value) || value.length > 5
335
+ || value.some(name => typeof name !== 'string' || !name.trim() || name.length > 40 || !/^[\p{L}\p{M}\p{N} '.-]+$/u.test(name)))) {
336
+ throw new Error('Wanted and avoid can list up to five names, each up to 40 characters.');
337
+ }
338
+ }
339
+ if (round !== undefined && (!Number.isInteger(round) || round < 1 || round > 20)) throw new Error('Choose a round from 1 to 20.');
340
+ return { idea: idea.trim(), ...(wanted && { wanted }), ...(avoid && { avoid }), ...(round && { round }) };
341
+ }
342
+
286
343
  // The capability prints one JSON object on stdout.
287
344
  function parseOutput(stdout, failed, stoppedAfter) {
288
345
  if (stoppedAfter) {
@@ -422,18 +479,18 @@ function pendingTriage(progress, rows) {
422
479
  export async function serve({
423
480
  input = process.stdin, output = process.stdout, cwd = capabilityDir, timeout = timeoutMs, maxLookup = maxLookupMs,
424
481
  pages = resultPages(), watch = watchDomain, socialLookup = checkSocialHandles, dossier = domainDossier, portfolio = myDomains,
425
- onLookupEvent,
482
+ onLookupEvent, scoreLog = scoreLogger(), hosted = cwd === capabilityDir ? hostedClient(serverVersion) : null,
426
483
  } = {}) {
427
484
  const send = response => output.write(JSON.stringify({ jsonrpc: '2.0', ...response }) + '\n');
428
485
  const error = (id, code, message) => send({ id, error: { code, message } });
429
486
  const pending = new Set();
430
487
  const lookups = new Map();
488
+ const generations = new Map();
431
489
  const background = new Set();
432
490
 
433
491
  // Join the running or finished lookup for the same input, or start one. Answer within the budget with the
434
492
  // result, or with the progress so far while the lookup keeps running for a repeated call to collect.
435
- async function runLookup(args, buildArgs, rowsFor, render, renderProgress, onLookup = () => {}) {
436
- const started = performance.now();
493
+ async function runLookup(args, buildArgs, rowsFor, render, renderProgress, onLookup = () => {}, started = performance.now()) {
437
494
  let cliArgs;
438
495
  let rows;
439
496
  try {
@@ -484,6 +541,75 @@ export async function serve({
484
541
  return tracked;
485
542
  };
486
543
 
544
+ async function hostedLookup(args, triage) {
545
+ if (!hosted || args?.confirm === true || (triage && args?.additionalHandles?.length)) return null;
546
+ let checks;
547
+ try {
548
+ (triage ? triageArguments : cliArguments)(args);
549
+ const rows = (triage ? triageRows : checkRows)(args);
550
+ if (!rows.length || (triage && args.names.some(name => !normalizeName(name)))) return null;
551
+ const extra = selectedEndings(args).filter(ending => !defaultEndings.includes(ending));
552
+ const signal = AbortSignal.timeout(Math.max(1, Math.min(13_000, Math.floor(timeout - 750))));
553
+ checks = await Promise.all(rows.map(({ name }) => hosted.check(name, name.includes('.') ? [] : extra, signal)));
554
+ } catch (problem) {
555
+ if (problem instanceof HostedRateLimit) return errorResult('The Hound needs a breather. Try again in a few minutes.');
556
+ return null;
557
+ }
558
+ try {
559
+ const evidence = hostedChecks(checks, args, triage);
560
+ const page = await pages(hostedResult(evidence, args), args, { triage });
561
+ if (triage && scoreLog?.enabled) {
562
+ const scored = evidence.filter(check => Number.isInteger(check.score?.value))
563
+ .sort((a, b) => compareScores(a.score, b.score));
564
+ track(scoreLog.shown(scored.slice(0, args.shortlist ? 8 : scored.length).map(({ query, score }) => ({
565
+ label: query.ascii, name: query.name, score,
566
+ }))));
567
+ }
568
+ return toolResult(JSON.stringify(triage ? page : withCheckQuoteOffer(page, args)));
569
+ } catch {
570
+ return errorResult('Domain Hound could not format the result.');
571
+ }
572
+ }
573
+
574
+ async function generateNames(args) {
575
+ let input;
576
+ try {
577
+ input = generationArguments(args);
578
+ } catch (problem) {
579
+ return errorResult(problem.message);
580
+ }
581
+ const local = () => toolResult(JSON.stringify({ display: attributed(
582
+ 'Use this naming method, then send your candidates to triage_names with names and shortlist: true.\n\n'
583
+ + namingRecipe(input.idea)), source: 'local' }));
584
+ if (!hosted) return local();
585
+ const key = JSON.stringify(input);
586
+ let job = generations.get(key);
587
+ if (!job) {
588
+ job = { page: null };
589
+ generations.set(key, job);
590
+ const write = (generation, pending = false, failed = false) => pages(
591
+ hostedResult(generatedChecks(generation), {}, generation, { pending, failed }), {},
592
+ { triage: true, reuse: job.page?.resultPage, refresh: pending },
593
+ ).then(page => { job.page = page; });
594
+ job.initial = (async () => {
595
+ const initial = await hosted.generate(input, AbortSignal.timeout(Math.max(1, Math.floor(timeout - 750))));
596
+ const pending = initial.stage === 'initial' && typeof initial.details?.id === 'string';
597
+ await write(initial, pending);
598
+ if (pending) track(hosted.finishGeneration(initial).then(final => write(final), () => write(initial, false, true)));
599
+ })();
600
+ job.initial.then(() => {
601
+ setTimeout(() => { if (generations.get(key) === job) generations.delete(key); }, keepFinishedMs).unref();
602
+ }, () => generations.delete(key));
603
+ }
604
+ try {
605
+ await job.initial;
606
+ return toolResult(JSON.stringify(job.page));
607
+ } catch (problem) {
608
+ return problem instanceof HostedRateLimit
609
+ ? errorResult('The Hound needs a breather. Try again in a few minutes.') : local();
610
+ }
611
+ }
612
+
487
613
  // The handle rows for one set of extra platforms, shared by every call on the same lookup.
488
614
  function handleCheck(lookup, args) {
489
615
  const extraPlatforms = args.additionalHandles ?? [];
@@ -525,14 +651,51 @@ export async function serve({
525
651
  evidence.handles = Object.fromEntries(entries.map(([name, rows]) => [name, {
526
652
  taken: rows.filter(row => row.state === 'taken').map(row => row.platform),
527
653
  not_found: rows.filter(row => row.state === 'not-found').map(row => row.platform),
528
- check: rows.filter(row => row.state === 'check').map(row => row.platform),
654
+ not_seen: rows.filter(row => row.state === 'not-seen').map(row => row.platform),
655
+ check: rows.filter(row => row.state === 'unknown').map(row => row.platform),
529
656
  }]));
530
657
  if (!check.rows) {
531
658
  evidence.handlesPending = true;
532
659
  running = true;
533
660
  }
661
+ rescore(evidence, handleRows);
662
+ }
663
+ const page = await writeTriagePage(lookup, evidence, args, running);
664
+ if (!running && !lookup.scoreLogged) {
665
+ lookup.scoreLogged = true;
666
+ logShown(evidence, args.shortlist);
667
+ }
668
+ return page;
669
+ }
670
+
671
+ // The screen scored names before the handle checks; score again with GitHub, npm and Bluesky as they land, and
672
+ // put the top picks back in score order.
673
+ function rescore(evidence, handleRows) {
674
+ evidence.receiptDetails = evidence.receiptDetails.map((detail, index) => {
675
+ const rows = handleRows.get(evidence.names[index].name);
676
+ if (!detail?.scoreInput || !rows) return detail;
677
+ const score = scoreName({ ...detail.scoreInput, handles: scoreHandles(rows) });
678
+ if (detail.score?.overridesAvoid && score.value != null) score.overridesAvoid = true;
679
+ evidence.names[index] = { ...evidence.names[index], score: compactScore(score) };
680
+ return { ...detail, score };
681
+ });
682
+ if (Array.isArray(evidence.top)) {
683
+ const scoreOf = name => evidence.names.find(row => row.name === name)?.score;
684
+ evidence.top = evidence.top.map((row, index) => ({ row, index }))
685
+ .sort((a, b) => compareScores(scoreOf(a.row.name), scoreOf(b.row.name)) || a.index - b.index).map(({ row }) => row);
534
686
  }
535
- return writeTriagePage(lookup, evidence, args, running);
687
+ }
688
+
689
+ // One log line per scored name, once its checks are done; only when the person turned the local log on.
690
+ function logShown(evidence, shortlist) {
691
+ if (!scoreLog?.enabled) return;
692
+ const rows = (evidence.receiptDetails ?? []).flatMap((detail, index) => {
693
+ const row = evidence.names[index];
694
+ const score = detail?.score;
695
+ return !Number.isInteger(score?.value) || score.pending || (shortlist && !scoreEligible({ ...row, ...detail }))
696
+ ? [] : [{ label: normalizeName(row.name), name: row.name, score }];
697
+ });
698
+ track(scoreLog.shown(rows.sort((a, b) => compareScores(a.score, b.score))));
536
699
  }
537
700
 
538
701
  // After the answer: run the handle checks and collect the follow-up, rewriting the same page as each one lands.
@@ -618,7 +781,7 @@ export async function serve({
618
781
  protocolVersion: versions.includes(version) ? version : versions[0],
619
782
  capabilities: { tools: {} },
620
783
  serverInfo: { name: 'domain-hound', title: 'Domain Hound', version: serverVersion },
621
- instructions: 'When you use Domain Hound, include its clickable Results page link in your final answer, including for a single exact domain. Copy the first line of say for the link, then give your short answer. For a new product name, generate five candidates and call triage_names once with shortlist: true.',
784
+ instructions: 'When you use Domain Hound, include its clickable Results page link in your final answer, including for a single exact domain. Copy the first line of say for the link, then give your short answer. For a new product name, call triage_names with idea. To check names you already have, pass names.',
622
785
  });
623
786
  }
624
787
  if (method !== 'tools/list' && method !== 'tools/call') return error(id, -32601, 'Method not found');
@@ -660,7 +823,11 @@ export async function serve({
660
823
  }
661
824
  }
662
825
  const purchase = isObject(args) && args.purchase === true;
826
+ const started = performance.now();
663
827
  if (name === triageTool.name) {
828
+ if (isObject(args) && Object.hasOwn(args, 'idea')) return reply(await generateNames(args));
829
+ const fromHost = await hostedLookup(args, true);
830
+ if (fromHost) return reply(fromHost);
664
831
  let current;
665
832
  const result = await runLookup(args, triageArguments, triageRows, (data, lookup) => triageReceipt(lookup, args, data),
666
833
  async (progress, timing, lookup) => {
@@ -676,7 +843,7 @@ export async function serve({
676
843
  const shown = JSON.parse(summary);
677
844
  shown.display = resultsLine(resultPage) + '\n' + shown.display;
678
845
  return JSON.stringify({ ...shown, resultPage });
679
- }, lookup => { current = lookup; });
846
+ }, lookup => { current = lookup; }, started);
680
847
  reply(result);
681
848
  if (!result.isError && current?.finished && current.outcome?.data) followUp(current);
682
849
  return;
@@ -684,8 +851,14 @@ export async function serve({
684
851
  if (name !== checkTool.name && name !== legacyTool.name) return error(id, -32602, 'Unknown tool');
685
852
  // An exact lookup includes the purchase line while its registration status is unsettled.
686
853
  const exact = isObject(args) && typeof args.query === 'string' && args.query.includes('.');
687
- return reply(await runLookup(args, cliArguments, checkRows, data => pages(data, args).then(page => withCheckQuoteOffer(page, args)),
688
- (progress, timing) => progressText(progress, { ...timing, purchase: purchase || exact })));
854
+ const result = await hostedLookup(args, false) ?? await runLookup(
855
+ args, cliArguments, checkRows, data => pages(data, args).then(page => withCheckQuoteOffer(page, args)),
856
+ (progress, timing) => progressText(progress, { ...timing, purchase: purchase || exact }), undefined, started,
857
+ );
858
+ if (exact && args.picked === true && !result.isError && result.structuredContent?.resultPage) {
859
+ track(scoreLog?.picked(args.query, 'check_domains'));
860
+ }
861
+ return reply(result);
689
862
  }
690
863
 
691
864
  const lines = createInterface({ input, terminal: false, crlfDelay: Infinity });
package/share.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import { deflateSync } from 'node:zlib';
2
- import { shareDomain, shareName, shareNameLimit, sharePage, shareRecordLimit, shareStatuses, shareUrlLimit,
2
+ import { scoreShareVersion, shareDomain, shareName, shareNameLimit, sharePage, shareRecordLimit, shareStatuses, shareUrlLimit,
3
3
  shareVerdicts, shareVersion } from './site/r/share-format.mjs';
4
4
 
5
5
  function cents(value) {
@@ -9,11 +9,13 @@ function cents(value) {
9
9
  }
10
10
 
11
11
  // facts[i] is what the local receipt chose for groups[i], as rows of that group: { pick, value, taken }.
12
- // Only those derived rows travel; the brief, budget, preferred endings and evidence stay local.
12
+ // Only those derived rows travel; the brief, budget, preferred endings and evidence stay local. A finished Name score
13
+ // travels as its value and the number of checks not done; its reasons and components stay local.
13
14
  export function shareUrl(groups, checkedAt, facts = []) {
14
15
  const timestamp = Date.parse(checkedAt);
15
16
  if (!groups.length || !Number.isFinite(timestamp)) return null;
16
17
  const shortlist = [];
18
+ let scored = false;
17
19
  for (const [index, { row, records }] of groups.slice(0, shareNameLimit).entries()) {
18
20
  if (!records.length || records.length > shareRecordLimit) return null;
19
21
  const base = records.length > 1 ? records[0].domain.split('.')[0] : '';
@@ -21,7 +23,10 @@ export function shareUrl(groups, checkedAt, facts = []) {
21
23
  let jumps = 0;
22
24
  let cloudflare = 0;
23
25
  for (const [position, { domain, status, now, renew, term, jump, dns }] of records.entries()) {
24
- const state = shareStatuses.indexOf(status);
26
+ // Older receipt readers use these status strings at the same wire positions.
27
+ const wireStatus = status === 'Available at the registry' ? 'Free at the registry'
28
+ : status === 'Check at shop, possibly available by DNS' ? 'Check at shop, likely free by DNS' : status;
29
+ const state = shareStatuses.indexOf(wireStatus);
25
30
  if (typeof domain !== 'string' || domain.length > 253 || !shareDomain.test(domain) || state < 0) return null;
26
31
  const part = domain.startsWith(base + '.') ? domain.slice(base.length) : domain;
27
32
  endings.push([part, state, cents(now), cents(renew), term ?? 1]);
@@ -32,14 +37,19 @@ export function shareUrl(groups, checkedAt, facts = []) {
32
37
  const rowOf = record => records.indexOf(record);
33
38
  const total = value && cents(value.total);
34
39
  if ([pick, value, ...taken].some(record => record && rowOf(record) < 0) || (value && total === null)) return null;
40
+ const score = row.score;
41
+ const shareScore = Number.isInteger(score?.value) && score.value >= 0 && score.value <= 100 && !score.pending
42
+ ? [score.value, Math.min(7, Array.isArray(score.notChecked) ? score.notChecked.length : 0)] : null;
43
+ if (shareScore) scored = true;
35
44
  const meta = { ...(pick && { p: rowOf(pick) }), ...(value && { b: [rowOf(value), total] }),
36
- ...(jumps && { j: jumps }), ...(taken.length && { t: taken.map(rowOf) }), ...(cloudflare && { c: cloudflare }) };
45
+ ...(jumps && { j: jumps }), ...(taken.length && { t: taken.map(rowOf) }), ...(cloudflare && { c: cloudflare }),
46
+ ...(shareScore && { s: shareScore }) };
37
47
  const display = row.name.trim().normalize('NFC');
38
48
  const name = shareName.test(display) ? display : records[0].domain;
39
49
  shortlist.push([name, Math.max(0, shareVerdicts.indexOf(row.verdict)), base, endings,
40
50
  ...(Object.keys(meta).length ? [meta] : [])]);
41
51
  }
42
52
  const packed = deflateSync(JSON.stringify([new Date(timestamp).toISOString(), shortlist]), { level: 9 });
43
- const url = sharePage + '#' + shareVersion + packed.toString('base64url');
53
+ const url = sharePage + '#' + (scored ? scoreShareVersion : shareVersion) + packed.toString('base64url');
44
54
  return url.length < shareUrlLimit ? url : null;
45
55
  }
@@ -4,12 +4,18 @@
4
4
  // { p: pick row, b: [best value row, three-year payments in cents], j: renewal-jump bit mask by row, t: taken rows, preferred first,
5
5
  // c: bit mask of rows whose price needs Cloudflare DNS }. A link carries c only when such a row is shown.
6
6
  // Version 1 links have no facts: they decode with no pick or best value and with jumps worked out from their prices.
7
+ // Version 3 is version 2 plus one optional fact, s: [Name score 0 to 100, number of checks not done]. Links without a
8
+ // score stay version 2, so readers that know only versions 1 and 2 keep opening them.
7
9
  export const sharePage = 'https://domainhound.dev/r/';
8
10
  export const shareUrlLimit = 2000;
9
11
  export const shareNameLimit = 5;
10
12
  export const shareRecordLimit = 28;
11
13
  export const shareVersion = '2.';
12
- const versions = { '1.': 1, '2.': 2 };
14
+ export const scoreShareVersion = '3.';
15
+ const versions = { '1.': 1, '2.': 2, '3.': 3 };
16
+ // Name score bands and label (Name score v1). The viewer and the local results share them.
17
+ export const scoreLabel = 'how clear the road is';
18
+ export const scoreBand = value => value >= 80 ? 'Strong' : value >= 60 ? 'Workable' : value >= 40 ? 'Risky' : 'Advise against';
13
19
  export const shareVerdicts = [null, 'No conflict found', 'Check first', 'Avoid'];
14
20
  export const shareStatuses = [
15
21
  'Free at the registry',
@@ -34,11 +40,15 @@ const isCents = value => value === null || (Number.isSafeInteger(value) && value
34
40
  const dollars = value => value === null ? null : value / 100;
35
41
  const isTaken = row => /^Taken\b/.test(row.status);
36
42
  const factKeys = ['p', 'b', 'j', 't', 'c'];
43
+ const scoredFactKeys = [...factKeys, 's'];
37
44
  export const cloudflareDns = 'Needs Cloudflare DNS';
38
45
 
39
- function parseFacts(facts, rows) {
40
- if (!facts || typeof facts !== 'object' || Array.isArray(facts) || Object.keys(facts).some(key => !factKeys.includes(key))) return null;
41
- const { p: pick = null, b: best = null, j: jumps = 0, t: taken = [], c: cloudflare = 0 } = facts;
46
+ function parseFacts(facts, rows, version) {
47
+ const keys = version >= 3 ? scoredFactKeys : factKeys;
48
+ if (!facts || typeof facts !== 'object' || Array.isArray(facts) || Object.keys(facts).some(key => !keys.includes(key))) return null;
49
+ const { p: pick = null, b: best = null, j: jumps = 0, t: taken = [], c: cloudflare = 0, s: score = null } = facts;
50
+ if (score !== null && !(Array.isArray(score) && score.length === 2 && Number.isInteger(score[0]) && score[0] >= 0 && score[0] <= 100
51
+ && Number.isInteger(score[1]) && score[1] >= 0 && score[1] <= 7)) return null;
42
52
  const validIndex = index => Number.isInteger(index) && index >= 0 && index < rows.length;
43
53
  const available = index => validIndex(index) && ['Free at the registry', 'Confirmed at shop'].includes(rows[index].status);
44
54
  if ((pick !== null && !available(pick))
@@ -52,6 +62,7 @@ function parseFacts(facts, rows) {
52
62
  ...(best?.[0] === index && { bestValue: dollars(best[1]) }),
53
63
  ...(Math.floor(cloudflare / 2 ** index) % 2 === 1 && { dns: cloudflareDns }) })),
54
64
  takenDomains: taken.map(index => rows[index].domain),
65
+ ...(score && { score: { value: score[0], band: scoreBand(score[0]), notChecked: score[1] } }),
55
66
  };
56
67
  }
57
68
 
@@ -91,7 +102,7 @@ function parseReceipt(receipt, version) {
91
102
  || !isCents(now) || !isCents(renew) || !Number.isInteger(term) || term < 1 || term > 10) return null;
92
103
  endings.push({ domain, status: shareStatuses[status], now: dollars(now), renew: dollars(renew), term });
93
104
  }
94
- const facts = version === 1 ? legacyFacts(endings) : parseFacts(group[4] ?? {}, endings);
105
+ const facts = version === 1 ? legacyFacts(endings) : parseFacts(group[4] ?? {}, endings, version);
95
106
  if (!facts) return null;
96
107
  parsed.push({ name, verdict: shareVerdicts[verdict], ...facts });
97
108
  }
@@ -0,0 +1,76 @@
1
+ ---
2
+ name: naming
3
+ description: Name a product, company, tool or domain. Use for any "what should we call it" request. Gives distinctive, protectable names with an available domain, ranked by Name score.
4
+ ---
5
+
6
+ # Naming
7
+
8
+ The same method as Domain Hound's `naming_method` tool. English names unless asked otherwise. The name must last: no rebrand later.
9
+
10
+ ## Process
11
+
12
+ 1. **Brief.** Read the repo or README if there is one. Otherwise ask at most three questions: what it does and for whom; the feel in two adjectives; competitors or names to avoid.
13
+ 2. **Subject words.** List about 30 words from the subject: objects, verbs, tools, places, roles, jargon, sounds.
14
+ 3. **Territories.** Pick 6 directions of meaning or sound (for example craft, animal, weather, mischief, speed, kitchen). Note which name types competitors use and aim for the gap.
15
+ 4. **Generate.** 150 names per round, 25 per territory, mixing every recipe below. No judging yet. Every name contains or puns on a subject word.
16
+ 5. **Filter before checking.** Drop hard bans, names over 12 letters or 3 syllables, names with more than one plausible spelling when heard, names that are hard to say aloud, and near-twins. Keep about 40.
17
+ 6. **Check and score.** Call the Domain Hound `triage_names` tool once with your best eight, strongest first, a short `about`, and `candidates` evidence for each name (recipe, relation, spellings, realWord, descriptive, misspelled, narrow, soundsLike, badMeaning, language). It checks domains, trademarks, rivals, apps, handles and bad meanings, runs the bans in code, and returns a Name score v1 per name. Missing evidence and failed checks read "not checked", never clear. Repeat in batches for more names.
18
+ 7. **Show.** Only names with an available domain, ranked by score, top 8, at least three recipes represented. If fewer than 5 pass, say so and run another round; never pad.
19
+ 8. **Steer.** Ask the steering question. Work out what the two loved names share (recipe, territory, sound, length) and what the hated one signals. Run a new round of 150 in that direction. Never re-show a rejected name.
20
+
21
+ ## Recipes
22
+
23
+ Aim for suggestive or arbitrary: the name hints at the subject and never describes it.
24
+
25
+ | Recipe | Pattern | Example shapes |
26
+ |---|---|---|
27
+ | Odd pair (default) | subject word + unexpected concrete real word (animal, object, weather) | Loomfox, Ledgermoth |
28
+ | Pun | familiar word or phrase with a subject word swapped in by sound | Grepvine, Lintroller |
29
+ | Blend | subject word fused with a real word on a shared syllable; both stay audible | Inboxer, Schemantis |
30
+ | Insider term | vivid jargon from the subject that outsiders hear as an image | Second Proof, Cold Kerf |
31
+ | Phrase or character | short command or persona built on a subject word | Hush Inbox, Captain Diff |
32
+
33
+ Prefer concrete imagery, hard consonants, two syllables and a story you can tell in one sentence.
34
+
35
+ ## Hard bans
36
+
37
+ - Pure descriptive: two subject words, or subject word + generic word (hub, base, flow, labs, app, pro).
38
+ - Pure invented: no real word inside.
39
+ - Trend marks: -ly, -ify, -io, dropped vowels, deliberate misspellings, numbers, hyphens.
40
+ - "AI", "GPT", "bot" or "smart" in the name.
41
+ - Sounds like a competitor, a drug or a Pokemon.
42
+ - Too narrow: names one feature, not the product.
43
+ - Invented origin stories or claims about real brands.
44
+
45
+ ## Red flags (penalise, note)
46
+
47
+ Easy to mock; mild bad meaning; a dormant site with the same name; needs spelling out on the phone; three syllables.
48
+
49
+ ## What to show
50
+
51
+ For each name, use this format. The price and score below are from a fixture.
52
+
53
+ **Loomfox** · Name score 91/100, Strong · loomfox.com, $29 for 3 years
54
+ - Best point first (for example ".com is available")
55
+ - Biggest loss
56
+ - Second loss, or "not checked: <what>"
57
+
58
+ Label the score "how clear the road is". It is not a probability.
59
+
60
+ Then ask exactly: **"Which two do you love, and which one do you hate?"**
61
+
62
+ ## Compact prompt (small model)
63
+
64
+ You name products. Input: a subject and its subject words.
65
+ Write 20 English names, one per line, format `Name | recipe | subject word used`.
66
+ Rules:
67
+ - Every name contains or puns on one subject word.
68
+ - Use these recipes in turn: (1) subject word + unexpected concrete real word, like Loomfox; (2) pun on a familiar word, like Grepvine; (3) blend on a shared syllable, like Inboxer; (4) short phrase or character, like Captain Diff.
69
+ - At most 12 letters and 3 syllables, one obvious spelling, easy to say.
70
+ - Never: two subject words together; made-up words with no real word inside; -ly, -ify, -io, hub, base, flow, labs, AI, bot; misspellings, numbers, hyphens.
71
+ - No explanations, no duplicates.
72
+ Fallback when the model fails: pair each subject word with a fixed list of concrete nouns (animals, tools, weather) and apply the same bans.
73
+
74
+ ## Name score v1
75
+
76
+ 0 to 100, labelled "how clear the road is". Points: best available ending 22, 3-year price 3, trademark 25, rivals 20, apps 8, handles 7 (GitHub 3, npm 2, Bluesky 2), name quality 15. A failed check earns 40% of its points and says "not checked". Trademark stays at 20 or less until the EU office answers; a failed US trademark or rival check, or missing ban evidence, keeps the total at 79 or less. Bands: 80+ Strong, 60 to 79 Workable, 40 to 59 Risky, under 40 Advise against. Bans and hard filters (no available ending within $60 over 3 years, identical live trademark in your classes, a strong same-name rival in your subject, a severe bad meaning, not English unless asked) remove a name before scoring.