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.
- package/.claude-plugin/plugin.json +1 -1
- package/README.md +34 -7
- package/assets/readme-search.png +0 -0
- package/clis/domain-check/company-search.mjs +1 -0
- package/clis/domain-check/handles.mjs +337 -0
- package/clis/domain-check/index.mjs +42 -11
- package/clis/domain-check/name-search.mjs +37 -11
- package/clis/domain-check/naming-method.mjs +3 -3
- package/clis/domain-check/price-catalog.mjs +20 -12
- package/clis/domain-check/price-snapshot.json +142 -10
- package/clis/domain-check/registry.mjs +110 -17
- package/clis/domain-check/traction.mjs +9 -6
- package/clis/domain-check/triage-sources.mjs +13 -52
- package/clis/domain-check/triage.mjs +134 -40
- package/display.mjs +7 -4
- package/package.json +21 -5
- package/plugin.json +2 -2
- package/results-style.mjs +62 -0
- package/results.mjs +447 -0
- package/server.json +3 -12
- package/server.mjs +149 -40
- package/watch.mjs +93 -0
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
// Domain Hound's brand B receipt, designed for the same table at phone and desktop widths.
|
|
2
|
+
export const receiptStyle = `
|
|
3
|
+
:root {
|
|
4
|
+
color-scheme: light;
|
|
5
|
+
--blue: #102385;
|
|
6
|
+
--gold: #f4c64f;
|
|
7
|
+
--cream: #fff7de;
|
|
8
|
+
--lime: #cdf473;
|
|
9
|
+
--coral: #ffab91;
|
|
10
|
+
--mono: ui-monospace, "SFMono-Regular", Consolas, monospace;
|
|
11
|
+
}
|
|
12
|
+
* { box-sizing: border-box; }
|
|
13
|
+
body {
|
|
14
|
+
margin: 0;
|
|
15
|
+
background: var(--cream);
|
|
16
|
+
color: var(--blue);
|
|
17
|
+
font: 400 1.0625rem/1.5 Mulish, system-ui, sans-serif;
|
|
18
|
+
overflow-wrap: anywhere;
|
|
19
|
+
}
|
|
20
|
+
main { width: min(calc(100% - 2rem), 56rem); margin: 1rem auto 3rem; }
|
|
21
|
+
main > header {
|
|
22
|
+
padding: .875rem 1rem;
|
|
23
|
+
background: var(--blue);
|
|
24
|
+
color: var(--cream);
|
|
25
|
+
border-bottom: .3rem solid var(--gold);
|
|
26
|
+
}
|
|
27
|
+
header small, time, code { font-family: var(--mono); }
|
|
28
|
+
header small { color: var(--gold); font-weight: 700; }
|
|
29
|
+
h1, h2 { margin: 0; font-weight: 900; line-height: 1.12; letter-spacing: -.035em; }
|
|
30
|
+
h1 { margin-block: .2rem; font-size: clamp(2rem, 4vw, 2.75rem); }
|
|
31
|
+
h2 { font-size: 1.65rem; }
|
|
32
|
+
p { max-width: 62ch; margin: .35rem 0; }
|
|
33
|
+
main > section, article, footer { margin-top: 1.25rem; padding-top: 1rem; border-top: 2px solid var(--blue); }
|
|
34
|
+
.comparison { display: grid; gap: 2px; margin-block: .875rem; border: 2px solid var(--blue); background: var(--blue); }
|
|
35
|
+
.comparison > * { min-width: 0; margin: 0; padding: .6rem .8rem; background: var(--gold); }
|
|
36
|
+
.comparison > :last-child { background: var(--lime); }
|
|
37
|
+
nav { display: flex; flex-wrap: wrap; gap: 0 1rem; margin-top: 1rem; }
|
|
38
|
+
a, a:visited { color: inherit; text-underline-offset: .18em; }
|
|
39
|
+
nav a, summary { padding-block: .6rem; }
|
|
40
|
+
:focus-visible { outline: 3px solid currentColor; outline-offset: 2px; }
|
|
41
|
+
table { width: 100%; table-layout: fixed; border-collapse: collapse; margin-block: .75rem; }
|
|
42
|
+
caption { padding-bottom: .35rem; text-align: left; font-weight: 750; }
|
|
43
|
+
th, td { padding: .5rem .4rem; border-bottom: 1px solid var(--blue); text-align: left; vertical-align: top; }
|
|
44
|
+
thead { background: var(--blue); color: var(--cream); }
|
|
45
|
+
thead th:first-child { width: 50%; }
|
|
46
|
+
thead th:nth-child(n+2), tbody td { text-align: right; }
|
|
47
|
+
tbody td { font-variant-numeric: lining-nums tabular-nums; }
|
|
48
|
+
th[scope="row"] code { display: block; font-weight: 800; }
|
|
49
|
+
th[scope="row"] small { display: block; font: 400 .9375rem/1.45 system-ui, sans-serif; }
|
|
50
|
+
details { border-bottom: 1px dashed var(--blue); }
|
|
51
|
+
summary { cursor: pointer; font-weight: 750; }
|
|
52
|
+
details[open] { padding-bottom: .65rem; }
|
|
53
|
+
footer { font-size: .9375rem; }
|
|
54
|
+
@media (min-width: 48rem) {
|
|
55
|
+
body { font-size: 1.125rem; }
|
|
56
|
+
main { margin-top: 2rem; }
|
|
57
|
+
main > header { padding: 1rem 1.25rem; }
|
|
58
|
+
.comparison { grid-template-columns: repeat(2, minmax(0, 1fr)); }
|
|
59
|
+
thead th:first-child { width: 56%; }
|
|
60
|
+
th, td { padding: .55rem .85rem; }
|
|
61
|
+
}
|
|
62
|
+
`;
|
package/results.mjs
ADDED
|
@@ -0,0 +1,447 @@
|
|
|
1
|
+
import { spawn } from 'node:child_process';
|
|
2
|
+
import { randomUUID } from 'node:crypto';
|
|
3
|
+
import { mkdir, readdir, rename, stat, unlink, writeFile } from 'node:fs/promises';
|
|
4
|
+
import { homedir, userInfo } from 'node:os';
|
|
5
|
+
import { join, resolve } from 'node:path';
|
|
6
|
+
import { pathToFileURL } from 'node:url';
|
|
7
|
+
import { canRecommend, defaultEndings, domainEnding, eligibilityNeed, normalizeName } from './clis/domain-check/name-search.mjs';
|
|
8
|
+
import { handlePriorities, handleStates, handleSummary } from './clis/domain-check/handles.mjs';
|
|
9
|
+
import { shopSearchUrl, shops } from './clis/domain-check/prices.mjs';
|
|
10
|
+
import { safeLink } from './display.mjs';
|
|
11
|
+
import { receiptStyle } from './results-style.mjs';
|
|
12
|
+
|
|
13
|
+
const cash = value => Number.isFinite(value) ? '$' + value.toFixed(2) : null;
|
|
14
|
+
const escape = value => String(value ?? '').replace(/[&<>"']/g, char =>
|
|
15
|
+
({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' })[char]);
|
|
16
|
+
const plain = value => String(value ?? '').replace(/[\r\n\p{Cc}\p{Cf}]+/gu, ' ').replace(/\s*[—–]\s*/g, '. ').trim();
|
|
17
|
+
const evidenceText = value => plain(value).replace(/\[([^\]]*)\]\([^)]*\)/g, '$1')
|
|
18
|
+
.replace(/https?:\/\/[^\s)]+/gi, '').replace(/[\[\]<>]/g, '').replace(/\s{2,}/g, ' ').trim();
|
|
19
|
+
const markdown = value => plain(value).replace(/[\\|<>\[\]`*]/g, '\\$&');
|
|
20
|
+
const shopIds = new Map(Object.entries(shops).map(([id, { name }]) => [name, id]));
|
|
21
|
+
const fallbackShop = ending => ending === 'no' ? 'dynadot' : ending === 'so' ? 'namecheap' : 'spaceship';
|
|
22
|
+
const markOf = row => row.competition?.US;
|
|
23
|
+
const marksText = row => {
|
|
24
|
+
const mark = markOf(row);
|
|
25
|
+
return 'US marks: ' + (typeof mark === 'string' ? evidenceText(mark) : mark == null ? 'not checked' : 'no match found');
|
|
26
|
+
};
|
|
27
|
+
const watchLink = domain => 'https://domainhound.dev/watch/?domain=' + encodeURIComponent(domain);
|
|
28
|
+
const verdictOrder = { 'No conflict found': 0, 'Check first': 1, Avoid: 2 };
|
|
29
|
+
|
|
30
|
+
function resultGroups(data, eligibleEndings) {
|
|
31
|
+
return data.names.map((row, index) => {
|
|
32
|
+
const detail = data.receiptDetails?.[index] ?? {};
|
|
33
|
+
const exact = row.name.includes('.');
|
|
34
|
+
const label = exact ? row.name : normalizeName(row.name);
|
|
35
|
+
const listed = [...(row.free ?? []), ...(row.taken ?? []), ...(row.shop_check ?? []), ...(row.resale ?? []),
|
|
36
|
+
...(row.premium ?? []), ...(row.reserved ?? [])].map(value => value.d ?? value).filter(value => typeof value === 'string');
|
|
37
|
+
const variants = listed.filter(value => value.includes('.') && value !== 'co.uk');
|
|
38
|
+
// Endings on request (such as .de or .uk) join the default endings when the lookup returned them.
|
|
39
|
+
const extra = listed.filter(value => (!value.includes('.') || value === 'co.uk') && !defaultEndings.includes(value));
|
|
40
|
+
const targets = exact ? [row.name] : [...new Set([...[...defaultEndings, ...extra].map(ending => label + '.' + ending), ...variants])];
|
|
41
|
+
const records = targets.map(domain => {
|
|
42
|
+
const ending = domainEnding(domain);
|
|
43
|
+
const lookupKey = domain === label + '.' + ending || exact ? ending : domain;
|
|
44
|
+
const match = list => list?.find(value => (value.d ?? value) === domain || (value.d ?? value) === lookupKey);
|
|
45
|
+
const option = match(row.free);
|
|
46
|
+
const raw = detail.endings?.find(item => item.domain === domain);
|
|
47
|
+
const confirmed = option?.s === 'ok';
|
|
48
|
+
const quote = confirmed ? option : { ...data.listPrices?.[ending], ...data.listPrices?.[domain],
|
|
49
|
+
...data.prices?.[ending], ...row.own?.[ending], ...(typeof option === 'object' ? option : {}) };
|
|
50
|
+
const taken = Boolean(match(row.taken) || match(row.resale));
|
|
51
|
+
const reserved = Boolean(match(row.reserved));
|
|
52
|
+
const risk = Boolean(option?.risk || raw?.risk);
|
|
53
|
+
const premium = Boolean(match(row.premium) || option?.s === 'prem' || option?.prem || risk);
|
|
54
|
+
const includePrice = !reserved && (!premium || confirmed) && (!taken || exact);
|
|
55
|
+
const likely = match(row.likely_free) ? 'likely free by DNS' : match(row.likely_taken) ? 'likely taken by DNS' : null;
|
|
56
|
+
const state = taken ? 'taken' : premium ? 'premium' : option ? 'free' : 'check';
|
|
57
|
+
const status = taken ? (match(row.resale) ? 'Taken, possible resale' : 'Taken')
|
|
58
|
+
: reserved ? 'Not offered for registration' : confirmed ? 'Confirmed at shop'
|
|
59
|
+
: premium ? (risk ? 'May be premium, price at shop' : 'Premium, price at shop')
|
|
60
|
+
: option ? 'Free at the registry' : likely ? 'Check at shop, ' + likely
|
|
61
|
+
: data.pending && !match(row.shop_check) ? 'Still checking' : 'Check at shop';
|
|
62
|
+
const usd = includePrice ? { now: quote.now, renew: quote.renew, y3: quote.y3, term: quote.term,
|
|
63
|
+
jump: quote.jump, shop: quote.shop } : {};
|
|
64
|
+
const term = usd.term ?? 1;
|
|
65
|
+
const total = usd.y3 ?? (usd.now != null && usd.renew != null ? usd.now + (Math.ceil(3 / term) - 1) * usd.renew : null);
|
|
66
|
+
const source = ({ web: 'Live site', dns: 'DNS', rdap: 'Registry RDAP', whois: 'Registry WHOIS',
|
|
67
|
+
shop: 'Shop', list: 'Price list' })[raw?.source] ?? (confirmed ? 'Shop' : likely ? 'DNS' : 'Registry');
|
|
68
|
+
const shop = usd.shop ?? raw?.shop ?? shops[fallbackShop(ending)]?.name;
|
|
69
|
+
const eligible = canRecommend(ending, eligibleEndings ?? data.eligible);
|
|
70
|
+
const shopUrl = shopSearchUrl(shopIds.get(shop) ?? fallbackShop(ending), domain);
|
|
71
|
+
const checkout = taken || reserved || !eligible ? null : [raw?.checkout, shopUrl].find(url => safeLink(url, domain)) ?? null;
|
|
72
|
+
return { domain, ending, state, status, ...usd, total, shop, checkout, eligible, source,
|
|
73
|
+
priceLabel: usd.now != null || usd.renew != null ? (confirmed ? 'Shop quote' : taken ? 'Standard list price benchmark' : 'List price') : '',
|
|
74
|
+
checkedAt: raw?.checkedAt ?? data.checkedAt, priceAt: confirmed ? raw?.checkedAt ?? data.checkedAt : raw?.priceAt ?? data.priceListDate,
|
|
75
|
+
site: raw?.site ?? detail.details?.sites?.[ending] ?? row.details?.sites?.[ending] };
|
|
76
|
+
});
|
|
77
|
+
records.sort((a, b) => Number(b.state === 'free' || b.priceLabel === 'Shop quote')
|
|
78
|
+
- Number(a.state === 'free' || a.priceLabel === 'Shop quote') || (a.now ?? Infinity) - (b.now ?? Infinity));
|
|
79
|
+
return { row: { ...row, ...detail, name: row.name }, records };
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
function priceDate(offer) {
|
|
84
|
+
return offer.priceAt ? ' checked ' + offer.priceAt.slice(0, 10) : '';
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
function offerText(offer, linked = false) {
|
|
88
|
+
const { domain, checkout, now, renew, term, jump, priceLabel } = offer;
|
|
89
|
+
const price = now != null ? cash(now) + (renew != null ? ', then ' + cash(renew) : ', renewal at shop')
|
|
90
|
+
: renew != null ? cash(renew) + ' renewal' : 'price at shop';
|
|
91
|
+
return (linked && checkout ? '[' + domain + '](' + checkout + ')' : domain) + ' ' + price
|
|
92
|
+
+ (term > 1 ? ' every ' + term + ' years' : '') + (jump ? ' (renewal jumps)' : '')
|
|
93
|
+
+ (priceLabel ? ' ' + priceLabel.toLowerCase() + priceDate(offer) : '');
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
function appFinding(value) {
|
|
97
|
+
if (value == null) return 'check incomplete';
|
|
98
|
+
return Array.isArray(value) && !value.length ? 'no app with this name' : 'same-name app found';
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
function signals(group) {
|
|
102
|
+
const { row, records } = group;
|
|
103
|
+
const comp = row.competition ?? {};
|
|
104
|
+
const site = records.map(record => record.site).find(site => site?.state === 'live')?.host;
|
|
105
|
+
const states = records.map(record => typeof record.site === 'string' ? record.site : record.site?.state).filter(Boolean);
|
|
106
|
+
const checked = states.some(state => /^(?:live|parked|for.sale|no(?:-site| site found))/i.test(state));
|
|
107
|
+
const web = site ? 'live site at ' + plain(site) : states.some(state => /live/i.test(state)) ? 'live site'
|
|
108
|
+
: states.some(state => /parked|for sale|for-sale/i.test(state)) ? 'parked'
|
|
109
|
+
: row.traction?.domain ? 'rival listed at ' + plain(row.traction.domain)
|
|
110
|
+
: checked ? 'no live site found on checked endings' : 'not checked';
|
|
111
|
+
return 'iOS: ' + appFinding(comp.AppStore) + ' | Android: ' + appFinding(comp.GooglePlay) + ' | web: ' + web;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
function summary(groups, args, triage) {
|
|
115
|
+
const [wanted] = groups;
|
|
116
|
+
const preferred = args.endings ?? [];
|
|
117
|
+
const budget = args.budget;
|
|
118
|
+
const isExact = !triage && groups.length === 1 && wanted.row.name.includes('.');
|
|
119
|
+
const constraints = [...(!isExact && preferred.length ? [preferred.map(ending => '.' + ending).join(', ') + ' first'] : []),
|
|
120
|
+
...(budget != null ? ['Up to ' + cash(budget) + ' today'] : [])];
|
|
121
|
+
const inScope = record => record.eligible && (!preferred.length || preferred.includes(record.ending))
|
|
122
|
+
&& (budget == null || (record.now ?? Infinity) <= budget);
|
|
123
|
+
const candidates = groups.flatMap(group => group.row.verdict === 'Avoid' ? [] : group.records
|
|
124
|
+
.filter(record => inScope(record) && (record.state === 'free' || record.priceLabel === 'Shop quote'))
|
|
125
|
+
.map(record => ({ group, record })));
|
|
126
|
+
const cost = item => item.record.now ?? Infinity;
|
|
127
|
+
const compareCost = (a, b) => cost(a) - cost(b);
|
|
128
|
+
const position = item => preferred.length ? preferred.indexOf(item.record.ending) : 0;
|
|
129
|
+
candidates.sort((a, b) => (verdictOrder[a.group.row.verdict] ?? 0) - (verdictOrder[b.group.row.verdict] ?? 0)
|
|
130
|
+
|| position(a) - position(b) || compareCost(a, b) || a.record.domain.localeCompare(b.record.domain));
|
|
131
|
+
const best = candidates[0];
|
|
132
|
+
const picks = [...new Map(candidates.toReversed().map(item => [item.group, item])).values()].reverse().slice(0, 3);
|
|
133
|
+
const cheapest = candidates.filter(item => item.record.now != null).sort(compareCost)[0];
|
|
134
|
+
const value = candidates.filter(item => item.record.total != null)
|
|
135
|
+
.sort((a, b) => a.record.total - b.record.total || compareCost(a, b))[0];
|
|
136
|
+
const target = wanted.records.find(record => record.ending === (preferred[0] ?? 'com')) ?? wanted.records[0];
|
|
137
|
+
const watch = target?.state === 'taken' ? 'Want it anyway? [Watch ' + target.domain + '](' + watchLink(target.domain) + ').' : null;
|
|
138
|
+
if (isExact) {
|
|
139
|
+
const picked = wanted.records[0];
|
|
140
|
+
const hasPrice = picked.now != null || picked.renew != null;
|
|
141
|
+
let price = hasPrice ? ' ' + offerText(picked).slice(picked.domain.length + 1) + '.' : '';
|
|
142
|
+
if (picked.state === 'taken' && picked.renew != null) {
|
|
143
|
+
price = ' Standard list renewal: ' + cash(picked.renew) + (picked.term > 1
|
|
144
|
+
? ' every ' + picked.term + ' years (' + cash(picked.renew / picked.term) + ' a year)' : ' a year') + priceDate(picked) + '.';
|
|
145
|
+
}
|
|
146
|
+
const overBudget = budget != null && picked.now != null && picked.now > budget && picked.state !== 'taken';
|
|
147
|
+
const intro = picked.domain + ': ' + picked.status.toLowerCase() + '.' + price + (overBudget ? ' Over budget.' : '');
|
|
148
|
+
const step = overBudget ? 'Next: try a cheaper domain.' : picked.checkout
|
|
149
|
+
? 'Next: [check at ' + plain(picked.shop) + '](' + picked.checkout + ').' : watch ?? 'Next: check another domain.';
|
|
150
|
+
return [...constraints, intro, ...(args.purchase ? ['Domain Hound cannot buy or complete checkout.'] : []), step];
|
|
151
|
+
}
|
|
152
|
+
const reason = evidenceText(wanted.row.reason).replace('David vs Goliath: ', 'Established rival: ');
|
|
153
|
+
const keep = triage ? 'Keep ' + evidenceText(wanted.row.name) + '? ' + plain(wanted.row.verdict) + '. '
|
|
154
|
+
+ reason.replaceAll(' · ', '. ') + '.'
|
|
155
|
+
+ (typeof markOf(wanted.row) === 'string' && reason.includes(markOf(wanted.row)) ? ' US trademark screen.' : ' ' + marksText(wanted.row) + '.')
|
|
156
|
+
+ (wanted.row.verdict === 'Avoid' && best ? (best.group.row.verdict === 'No conflict found' ? ' Best free rename: ' : ' Next name to check: ')
|
|
157
|
+
+ plain(best.group.row.name) + '.' : '')
|
|
158
|
+
+ (picks.some(item => item.group === wanted) ? '' : ' | ' + signals(wanted)) : null;
|
|
159
|
+
const next = watch ?? (args.shortlist ? 'Next: screen the best names.' : best ? 'Next: check your pick at the shop.' : 'Next: try another name.');
|
|
160
|
+
const caution = item => item.group.row.verdict === 'Check first' ? ' (Check first)' : '';
|
|
161
|
+
const label = item => offerText(item.record, true) + caution(item);
|
|
162
|
+
const offerLines = picks.map(({ group, record }, index) =>
|
|
163
|
+
(budget != null && index === 0 ? 'Pick: ' : (index + 1) + '. ') + offerText(record) + ' (' + plain(record.status.toLowerCase()) + ') | '
|
|
164
|
+
+ (triage ? plain(group.row.verdict) + ' | ' + marksText(group.row) + ' | ' : '') + signals(group));
|
|
165
|
+
const scope = constraints.length ? constraints.join(' | ') + '. ' : '';
|
|
166
|
+
const leadPick = scope && offerLines.length ? scope + offerLines.shift() : null;
|
|
167
|
+
const eligibility = args.eligible?.includes('no') || cheapest?.record.ending === 'no'
|
|
168
|
+
|| value?.record.ending === 'no' || preferred.includes('no')
|
|
169
|
+
? ' .no needs a Norwegian address and organization or personal ID.' : '';
|
|
170
|
+
const waiting = Array.isArray(wanted.row.handles) && wanted.row.handles.filter(row => row.why === 'still checking').map(row => row.platform);
|
|
171
|
+
const handles = !triage ? null : waiting?.length
|
|
172
|
+
? 'still checking ' + waiting.join(', ') + '. Check links on the page'
|
|
173
|
+
: handleSummary(wanted.row.handles, { ordered: true });
|
|
174
|
+
const lines = [
|
|
175
|
+
leadPick || (scope ? scope + 'All endings are on the page.' : null),
|
|
176
|
+
keep,
|
|
177
|
+
handles && 'Handles for ' + evidenceText(wanted.row.name) + ': ' + plain(handles) + '.',
|
|
178
|
+
...offerLines,
|
|
179
|
+
'Cheapest: ' + (cheapest ? label(cheapest) : 'none found in scope.'),
|
|
180
|
+
'Best value: ' + (value ? value.record.domain + ', ' + cash(value.record.total) + ' in payments due in 3 years'
|
|
181
|
+
+ ' (' + value.record.priceLabel.toLowerCase() + priceDate(value.record) + ')' + caution(value) : 'needs a shop quote') + '.',
|
|
182
|
+
(args.purchase ? 'Domain Hound cannot buy or complete checkout. ' : '') + next + eligibility,
|
|
183
|
+
];
|
|
184
|
+
return lines.filter(Boolean);
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
function httpsLink(value) {
|
|
188
|
+
if (typeof value !== 'string') return null;
|
|
189
|
+
try {
|
|
190
|
+
const url = new URL(value);
|
|
191
|
+
return url.protocol === 'https:' && !url.username && !url.password ? url.href : null;
|
|
192
|
+
} catch {
|
|
193
|
+
return null;
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
function details(group) {
|
|
198
|
+
const { row } = group;
|
|
199
|
+
const comp = row.competition ?? {};
|
|
200
|
+
const titleAndLink = value => value && typeof value === 'object'
|
|
201
|
+
? [plain(value.name ?? value.domain ?? value.title), httpsLink(value.url)] : [plain(value)];
|
|
202
|
+
const ios = Array.isArray(comp.AppStore) ? comp.AppStore : comp.AppStore ? [comp.AppStore] : [];
|
|
203
|
+
const android = Array.isArray(comp.GooglePlay) ? comp.GooglePlay : comp.GooglePlay ? [comp.GooglePlay] : [];
|
|
204
|
+
const matches = [
|
|
205
|
+
['US marks: ' + (typeof markOf(row) === 'string' ? plain(markOf(row)) : markOf(row) == null ? 'check incomplete' : 'no match found'), httpsLink(comp.mark)],
|
|
206
|
+
...ios.map(value => ['iOS: ' + titleAndLink(value)[0], titleAndLink(value)[1]]),
|
|
207
|
+
...android.map(value => ['Android: ' + titleAndLink(value)[0], titleAndLink(value)[1]]),
|
|
208
|
+
...[...(comp.sameName?.Norway ?? []), ...(comp.sameName?.EDGAR ?? [])].map(company => [plain(
|
|
209
|
+
[company.name, company.employees != null ? company.employees + ' employees' : null].filter(Boolean).join(', ')), httpsLink(company.url)]),
|
|
210
|
+
...group.records.filter(row => row.site).map(({ domain, site }) => [
|
|
211
|
+
(site.host ?? domain) + ': ' + plain(site.state ?? site) + (site.title ? ', ' + plain(site.title) : ''),
|
|
212
|
+
httpsLink('https://' + (site.host ?? domain))]),
|
|
213
|
+
['Web search: ' + plain(row.google?.result ?? 'check incomplete'), httpsLink(row.google?.link)],
|
|
214
|
+
['iOS search', 'https://apps.apple.com/us/iphone/search?term=' + encodeURIComponent(row.name)],
|
|
215
|
+
['Android search', 'https://play.google.com/store/search?q=' + encodeURIComponent(row.name) + '&c=apps'],
|
|
216
|
+
...(row.traction ? [[plain(row.traction.rival ?? row.traction.name ?? ''),
|
|
217
|
+
httpsLink(row.traction.domain && 'https://' + row.traction.domain)],
|
|
218
|
+
...Object.values(row.traction).flat().filter(value => typeof value === 'string').map(value => [plain(value)])] : []),
|
|
219
|
+
...(typeof row.reason === 'string' ? row.reason.split(' · ').slice(1).map(value => [plain(value)]) : []),
|
|
220
|
+
];
|
|
221
|
+
return matches.filter(([text, href]) => text && (href || !/ search$/.test(text)));
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
// One line per platform in display order: Taken, No public profile found or Check yourself, with the profile link.
|
|
225
|
+
function handleLines(group) {
|
|
226
|
+
const rows = Array.isArray(group.row.handles) ? group.row.handles : [];
|
|
227
|
+
return rows.flatMap(row => {
|
|
228
|
+
const label = row.platform + ' @' + plain(row.handle) + ': ' + (handleStates[row.state] ?? handleStates.check);
|
|
229
|
+
const detail = row.why === 'still checking' ? ' · still checking' : row.checkedAt ? ' · checked ' + plain(row.checkedAt) : '';
|
|
230
|
+
return [[label + detail, httpsLink(row.link)], ...(row.variants ?? []).map(variant => [
|
|
231
|
+
row.platform + ' alternative @' + plain(variant.handle) + ': ' + (handleStates[variant.state] ?? handleStates.check),
|
|
232
|
+
httpsLink(variant.link),
|
|
233
|
+
])];
|
|
234
|
+
});
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
function nameSnapshot({ row, records }) {
|
|
238
|
+
const mark = row.competition?.US;
|
|
239
|
+
const apps = [row.competition?.AppStore, row.competition?.GooglePlay];
|
|
240
|
+
const open = records.filter(record => record.state === 'free' && record.eligible).length;
|
|
241
|
+
const blocked = records.filter(record => record.state === 'taken').length;
|
|
242
|
+
const handles = Array.isArray(row.handles) ? row.handles : [];
|
|
243
|
+
const taken = handles.filter(handle => handle.state === 'taken').length;
|
|
244
|
+
const absent = handles.filter(handle => handle.state === 'not-found').length;
|
|
245
|
+
const checks = handles.filter(handle => handle.state === 'check').length;
|
|
246
|
+
return [
|
|
247
|
+
'Domains ' + open + ' open' + (blocked ? ', ' + blocked + ' taken' : ''),
|
|
248
|
+
'Trademark ' + (mark == null ? 'check incomplete' : mark.length ? 'match found' : 'no US match'),
|
|
249
|
+
'Apps ' + (apps.some(value => value?.length) ? 'same-name listing' : apps.some(value => value == null) ? 'check incomplete' : 'no match'),
|
|
250
|
+
'Handles ' + (handles.length ? [taken ? taken + ' taken' : null,
|
|
251
|
+
absent + taken ? absent + ' of ' + (absent + taken) + ' with no public match' : null, checks ? checks + ' to check' : null].filter(Boolean).join(', ')
|
|
252
|
+
: 'outside top three'),
|
|
253
|
+
].join(' / ');
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
function handlePriority({ row }, companyType) {
|
|
257
|
+
if (!Array.isArray(row.handles) || !row.handles.length || !Object.hasOwn(handlePriorities, companyType)) return '';
|
|
258
|
+
return 'Handles to secure for this business: ' + handlePriorities[companyType].map(platform => {
|
|
259
|
+
const entry = row.handles.find(handle => handle.platform === platform);
|
|
260
|
+
return platform + ' ' + (entry?.why === 'still checking' ? 'still checking' : handleStates[entry?.state ?? 'check'].toLowerCase());
|
|
261
|
+
}).join(', ') + '.';
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
const anchor = (label, url) => '<a href="' + escape(url) + '">' + escape(label) + '</a>';
|
|
265
|
+
function summaryHtml(line) {
|
|
266
|
+
return Array.from(line.matchAll(/\[([^\]]+)\]\((https:\/\/[^\s)]+)\)/g)).reduce(({ html, offset }, match) =>
|
|
267
|
+
({ html: html + escape(line.slice(offset, match.index)) + anchor(match[1], match[2]), offset: match.index + match[0].length }),
|
|
268
|
+
{ html: '', offset: 0 });
|
|
269
|
+
}
|
|
270
|
+
function paragraph(line) {
|
|
271
|
+
const { html, offset } = summaryHtml(line);
|
|
272
|
+
return '<p>' + html + escape(line.slice(offset)) + '</p>';
|
|
273
|
+
}
|
|
274
|
+
const amountsFor = ({ now, renew }) => [cash(now) ?? 'No price', cash(renew) ?? 'No price'];
|
|
275
|
+
|
|
276
|
+
function rowNote(row) {
|
|
277
|
+
return [row.status, row.priceLabel, row.term > 1 ? row.term + ' years per payment' : null,
|
|
278
|
+
row.jump ? 'Renewal jumps' : null, !row.eligible ? '.' + row.ending + ' needs ' + eligibilityNeed(row.ending) : null,
|
|
279
|
+
row.source, row.checkedAt, row.priceAt ? 'Price checked ' + row.priceAt : null].filter(Boolean).join(' · ');
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
function render(groups, lines, checkedAt, coverage, watch, companyType) {
|
|
283
|
+
const title = watch ? 'Domain watch' : 'Domain results';
|
|
284
|
+
const [intro, ...body] = lines;
|
|
285
|
+
const comparison = body.filter(line => /^(?:Cheapest|Best value):/.test(line));
|
|
286
|
+
const before = body.filter(line => !comparison.includes(line)).slice(0, comparison.length ? -1 : undefined);
|
|
287
|
+
const after = comparison.length ? body.slice(-1) : [];
|
|
288
|
+
const sources = watch?.source ? 'Registry: ' + String(watch.source).toUpperCase() :
|
|
289
|
+
Object.entries(coverage ?? {}).map(([name, count]) => name + ' ' + count + '% answered').join(' · ');
|
|
290
|
+
const articles = groups.map((group, index) => {
|
|
291
|
+
const { row } = group;
|
|
292
|
+
const handles = handleLines(group);
|
|
293
|
+
const priority = handlePriority(group, companyType);
|
|
294
|
+
const rows = group.records.map(record => {
|
|
295
|
+
const [now, renew] = amountsFor(record);
|
|
296
|
+
return '<tr><th scope="row"><code>' + escape(record.domain) + '</code><small>' + escape(rowNote(record))
|
|
297
|
+
+ (record.checkout ? ' · ' + anchor(record.shop ?? 'Check at shop', record.checkout) : '')
|
|
298
|
+
+ '</small></th><td>' + escape(now) + '</td><td>' + escape(renew) + '</td></tr>';
|
|
299
|
+
});
|
|
300
|
+
return '<article id="name-' + index + '"><h2>' + escape(row.name) + '</h2>'
|
|
301
|
+
+ (row.verdict ? paragraph(plain(row.verdict) + '. ' + evidenceText(row.reason).split(' · ')[0]) + paragraph(nameSnapshot(group)) : '')
|
|
302
|
+
+ '<table><caption>Endings · USD before tax</caption><thead><tr><th scope="col">Ending</th><th scope="col">Today</th><th scope="col">Renewal</th></tr></thead><tbody>'
|
|
303
|
+
+ rows.join('') + '</tbody></table>'
|
|
304
|
+
+ (row.verdict ? '<details><summary>Trademark, app and web evidence</summary><ul>'
|
|
305
|
+
+ details(group).map(([label, url]) => '<li>' + (url ? anchor(label, url) : escape(label)) + '</li>').join('') + '</ul></details>' : '')
|
|
306
|
+
+ (handles.length ? '<details><summary>Handles</summary>' + (priority ? paragraph(priority) : '') + '<ul>'
|
|
307
|
+
+ handles.map(([label, url]) => '<li>' + (url ? anchor(label, url) : escape(label)) + '</li>').join('') + '</ul></details>'
|
|
308
|
+
: row.verdict ? '<p><small>Handles: checked for the top three names.</small></p>' : '')
|
|
309
|
+
+ '</article>';
|
|
310
|
+
});
|
|
311
|
+
const html = '<!doctype html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1">'
|
|
312
|
+
+ '<meta name="referrer" content="no-referrer"><meta http-equiv="Content-Security-Policy" content="default-src \'none\'; style-src \'unsafe-inline\'; base-uri \'none\'; form-action \'none\'">'
|
|
313
|
+
+ '<title>' + title + ' | Domain Hound</title><style>' + receiptStyle + '</style></head><body><main>'
|
|
314
|
+
+ '<header><small>Domain Hound</small><h1>' + title + '</h1><time>' + escape(checkedAt) + '</time></header><section>'
|
|
315
|
+
+ [intro, ...before].filter(Boolean).map(paragraph).join('')
|
|
316
|
+
+ (comparison.length ? '<div class="comparison">' + comparison.map(paragraph).join('') + '</div>' : '')
|
|
317
|
+
+ after.map(paragraph).join('') + '</section>'
|
|
318
|
+
+ (groups.length > 1 ? '<nav aria-label="Jump to a name">' + groups.map(({ row }, index) => anchor(row.name, '#name-' + index)).join(' ') + '</nav>' : '')
|
|
319
|
+
+ articles.join('') + '<footer>' + (sources ? paragraph(sources) : '') + '<p>You hold the leash.</p></footer></main></body></html>\n';
|
|
320
|
+
const md = ['# ' + title, '', 'Domain Hound · ' + checkedAt, '', ...lines, '',
|
|
321
|
+
...groups.flatMap(group => ['## ' + markdown(group.row.name), '',
|
|
322
|
+
...(group.row.verdict ? [markdown(group.row.verdict + '. ' + group.row.reason), markdown(nameSnapshot(group)), ''] : []),
|
|
323
|
+
'| Ending | Today (USD) | Renewal (USD) | Evidence | Shop |', '| --- | --- | --- | --- | --- |',
|
|
324
|
+
...group.records.map(record => '| ' + [record.domain, ...amountsFor(record), markdown(rowNote(record)),
|
|
325
|
+
record.checkout ? '[' + markdown(record.shop ?? 'Check at shop') + '](' + record.checkout + ')' : ''].join(' | ') + ' |'),
|
|
326
|
+
'', ...(group.row.verdict ? details(group).map(([label, url]) => '- ' + (url ? '[' + markdown(label) + '](' + url + ')' : markdown(label))) : []),
|
|
327
|
+
...(handleLines(group).length ? ['', '### Handles', '', ...(handlePriority(group, companyType) ? [markdown(handlePriority(group, companyType)), ''] : []), ...handleLines(group).map(([label, url]) =>
|
|
328
|
+
'- ' + (url ? '[' + markdown(label) + '](' + url + ')' : markdown(label)))] : []), '']),
|
|
329
|
+
...(sources ? [markdown(sources), ''] : []), 'You hold the leash.', ''].join('\n');
|
|
330
|
+
return { html, md };
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
export async function backgroundCommand(filename, env = process.env, platform = process.platform) {
|
|
334
|
+
if (env.DOMAIN_HOUND_OPEN === 'off' || env.CI || env.DOMAIN_HOUND_HEADLESS || env.SSH_CONNECTION || env.SSH_TTY) return null;
|
|
335
|
+
if (platform === 'darwin') {
|
|
336
|
+
const console = await stat('/dev/console').catch(() => null);
|
|
337
|
+
if (console?.uid === userInfo().uid) return ['/usr/bin/open', ['-g', filename]];
|
|
338
|
+
}
|
|
339
|
+
if (platform === 'win32' && /^(?:Console|RDP-Tcp#\d+)$/i.test(env.SESSIONNAME ?? '')) {
|
|
340
|
+
// SW_SHOWNOACTIVATE is forwarded to the file association handler. The existing browser may ignore it.
|
|
341
|
+
const path = Buffer.from(filename, 'utf8').toString('base64');
|
|
342
|
+
const script = `Add-Type -Namespace DomainHound -Name Shell -MemberDefinition @'
|
|
343
|
+
[System.Runtime.InteropServices.DllImport("shell32.dll", CharSet=System.Runtime.InteropServices.CharSet.Unicode, ExactSpelling=true)]
|
|
344
|
+
public static extern System.IntPtr ShellExecuteW(System.IntPtr parent, string verb, string file, string args, string directory, int show);
|
|
345
|
+
'@
|
|
346
|
+
$file = [Text.Encoding]::UTF8.GetString([Convert]::FromBase64String('${path}'))
|
|
347
|
+
$result = [DomainHound.Shell]::ShellExecuteW([IntPtr]::Zero, 'open', $file, $null, $null, 4)
|
|
348
|
+
if ($result.ToInt64() -le 32) { exit 1 }`;
|
|
349
|
+
return ['powershell.exe', ['-NoProfile', '-NonInteractive', '-STA', '-EncodedCommand', Buffer.from(script, 'utf16le').toString('base64')]];
|
|
350
|
+
}
|
|
351
|
+
if (platform === 'linux' && env.WAYLAND_DISPLAY && env.DBUS_SESSION_BUS_ADDRESS) {
|
|
352
|
+
// Leave activation to the compositor without giving the browser a startup or activation token.
|
|
353
|
+
const { XDG_ACTIVATION_TOKEN, DESKTOP_STARTUP_ID, ...backgroundEnv } = env;
|
|
354
|
+
return ['gio', ['open', pathToFileURL(filename).href], backgroundEnv];
|
|
355
|
+
}
|
|
356
|
+
return null;
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
async function writePrivate(filename, content) {
|
|
360
|
+
const temporary = filename + '.' + randomUUID() + '.tmp';
|
|
361
|
+
try {
|
|
362
|
+
await writeFile(temporary, content, { flag: 'wx', mode: 0o600 });
|
|
363
|
+
await rename(temporary, filename);
|
|
364
|
+
} finally {
|
|
365
|
+
await unlink(temporary).catch(() => {});
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
async function prune(directory, current) {
|
|
370
|
+
const owned = /^(?:\d{4}-\d{2}-\d{2}T\d{2}-\d{2}-\d{2}-\d{3}Z-[a-z0-9-]+-[a-f0-9]{8}\.(?:html|md)|session-[a-f0-9]{8}\.html)$/;
|
|
371
|
+
const files = (await readdir(directory)).filter(file => owned.test(file));
|
|
372
|
+
const groups = new Map();
|
|
373
|
+
for (const file of files) {
|
|
374
|
+
const base = file.slice(0, file.lastIndexOf('.'));
|
|
375
|
+
if (!groups.has(base)) groups.set(base, []);
|
|
376
|
+
groups.get(base).push(file);
|
|
377
|
+
}
|
|
378
|
+
const ranked = await Promise.all([...groups].map(async ([base, entries]) => ({ base, entries,
|
|
379
|
+
at: (await stat(join(directory, entries[0])).catch(() => null))?.mtimeMs ?? 0,
|
|
380
|
+
})));
|
|
381
|
+
ranked.sort((a, b) => Number(b.base === current) - Number(a.base === current) || b.at - a.at || b.base.localeCompare(a.base));
|
|
382
|
+
let slots = 20;
|
|
383
|
+
for (const { base, entries, at } of ranked) {
|
|
384
|
+
// A second MCP process may be committing a twin. Leave a recent incomplete pair alone.
|
|
385
|
+
if (!base.startsWith('session-') && entries.length === 1 && Date.now() - at < 60_000) continue;
|
|
386
|
+
if (entries.length <= slots) {
|
|
387
|
+
slots -= entries.length;
|
|
388
|
+
continue;
|
|
389
|
+
}
|
|
390
|
+
await Promise.all(entries.map(file => unlink(join(directory, file)).catch(() => {})));
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
export function resultPages({ env = process.env,
|
|
395
|
+
directory = env.DOMAIN_HOUND_RESULTS_DIR || join(homedir(), '.domain-hound', 'results') } = {}) {
|
|
396
|
+
const session = randomUUID().slice(0, 8);
|
|
397
|
+
let writes = Promise.resolve();
|
|
398
|
+
return (data, args, { triage = false, watch = false } = {}) => {
|
|
399
|
+
const work = writes.then(async () => {
|
|
400
|
+
const at = data.checkedAt ?? new Date().toISOString();
|
|
401
|
+
const groups = watch ? [] : resultGroups(data, args.eligible);
|
|
402
|
+
const lines = watch ? data.say.split('\n') : data.pending ? [
|
|
403
|
+
'Still checking trademark, app and web sources. Registry answers so far are on the page.',
|
|
404
|
+
'Repeat the same lookup to collect the rest.',
|
|
405
|
+
...(args.purchase ? ['Domain Hound cannot buy or complete checkout.'] : []),
|
|
406
|
+
] : summary(groups, args, triage);
|
|
407
|
+
const title = watch ? data.domain : groups[0]?.row.name;
|
|
408
|
+
await mkdir(directory, { recursive: true, mode: 0o700 });
|
|
409
|
+
// If a caller points us at a shared directory, don't expose the searched name in its listing.
|
|
410
|
+
const privateListing = process.platform === 'win32' || ((await stat(directory)).mode & 0o077) === 0;
|
|
411
|
+
const slug = (privateListing && normalizeName(String(title).split('.')[0]) || 'results').slice(0, 30);
|
|
412
|
+
const base = new Date().toISOString().replaceAll(/[:.]/g, '-') + '-' + slug + '-' + randomUUID().slice(0, 8);
|
|
413
|
+
const filename = resolve(directory, base + '.html');
|
|
414
|
+
const page = render(groups, lines, at, data.sources, watch ? data : null, args.companyType);
|
|
415
|
+
const markdownPath = resolve(directory, base + '.md');
|
|
416
|
+
await writePrivate(markdownPath, page.md);
|
|
417
|
+
try {
|
|
418
|
+
await writePrivate(filename, page.html);
|
|
419
|
+
} catch (error) {
|
|
420
|
+
await unlink(markdownPath).catch(() => {});
|
|
421
|
+
throw error;
|
|
422
|
+
}
|
|
423
|
+
const exact = !triage && groups.length === 1 && groups[0].row.name.includes('.');
|
|
424
|
+
if (!watch && !exact) {
|
|
425
|
+
const latest = resolve(directory, 'session-' + session + '.html');
|
|
426
|
+
await backgroundCommand(latest, env).then(async command => {
|
|
427
|
+
if (!command) return;
|
|
428
|
+
await writePrivate(latest, page.html);
|
|
429
|
+
const [executable, args, launchEnv] = command;
|
|
430
|
+
const browser = spawn(executable, args, { stdio: 'ignore', windowsHide: true, env: launchEnv });
|
|
431
|
+
browser.on('error', () => {});
|
|
432
|
+
browser.unref();
|
|
433
|
+
}).catch(() => {});
|
|
434
|
+
}
|
|
435
|
+
await prune(directory, base).catch(() => {});
|
|
436
|
+
const url = pathToFileURL(filename).href.replaceAll('(', '%28').replaceAll(')', '%29');
|
|
437
|
+
const say = [...lines, 'All endings: [Results page](' + url + ')'].join('\n');
|
|
438
|
+
const { receiptDetails, say: priorSay, display: priorDisplay, ...structured } = data;
|
|
439
|
+
if (triage && receiptDetails) structured.names = structured.names.map((row, index) => ({
|
|
440
|
+
...row, details: { ...row.details, sites: receiptDetails[index]?.details?.sites ?? {} },
|
|
441
|
+
}));
|
|
442
|
+
return { display: say, say, ...structured, checkedAt: at, resultPage: url };
|
|
443
|
+
});
|
|
444
|
+
writes = work.catch(() => {});
|
|
445
|
+
return work;
|
|
446
|
+
};
|
|
447
|
+
}
|
package/server.json
CHANGED
|
@@ -2,23 +2,14 @@
|
|
|
2
2
|
"$schema": "https://static.modelcontextprotocol.io/schemas/2025-12-11/server.schema.json",
|
|
3
3
|
"name": "dev.domainhound/domain-hound",
|
|
4
4
|
"title": "Domain Hound",
|
|
5
|
-
"description": "
|
|
5
|
+
"description": "Find a startup name and domain you can buy: availability, prices, app names, trademarks, handles.",
|
|
6
6
|
"websiteUrl": "https://domainhound.dev",
|
|
7
|
-
"version": "0.1.
|
|
7
|
+
"version": "0.1.5",
|
|
8
8
|
"packages": [
|
|
9
9
|
{
|
|
10
10
|
"registryType": "npm",
|
|
11
11
|
"identifier": "domain-hound",
|
|
12
|
-
"version": "0.1.
|
|
13
|
-
"transport": {
|
|
14
|
-
"type": "stdio"
|
|
15
|
-
}
|
|
16
|
-
},
|
|
17
|
-
{
|
|
18
|
-
"registryType": "mcpb",
|
|
19
|
-
"identifier": "https://github.com/lars-hv/domain-hound/releases/download/v0.1.3/domain-hound-0.1.3.mcpb",
|
|
20
|
-
"version": "0.1.3",
|
|
21
|
-
"fileSha256": "4deb38d2cffd4f8165e3828a05ea84c37584a0558beb9135156c3b5e526937b9",
|
|
12
|
+
"version": "0.1.5",
|
|
22
13
|
"transport": {
|
|
23
14
|
"type": "stdio"
|
|
24
15
|
}
|