@vargov/mcp 0.0.0-stage → 0.2.0
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/DATA-LICENSE.md +30 -0
- package/LICENSE +24 -0
- package/README.md +132 -2
- package/data/brand-facts.json +204 -0
- package/data/llms-configurator.txt +26 -0
- package/data/llms-en.txt +94 -0
- package/data/llms-ru.txt +95 -0
- package/data/manifest.json +61 -0
- package/data/open-skus.json +1 -0
- package/data/organization.jsonld +265 -0
- package/data/products.json +68278 -0
- package/data/sketchfab-models.json +1843 -0
- package/dist/bim.js +166 -0
- package/dist/brand.js +137 -0
- package/dist/catalog.js +331 -0
- package/dist/data.js +148 -0
- package/dist/dealers.js +171 -0
- package/dist/index.js +16 -0
- package/dist/server.js +113 -0
- package/package.json +54 -6
package/dist/catalog.js
ADDED
|
@@ -0,0 +1,331 @@
|
|
|
1
|
+
// Tool logic: search, composition card, configurator link. Pure functions over getData().
|
|
2
|
+
import { FAMILIES, LANGS, getData, normalizeCode } from './data.js';
|
|
3
|
+
import { dealerRouteLine } from './dealers.js';
|
|
4
|
+
export const SEARCH_LIMIT_MAX = 50;
|
|
5
|
+
export const SEARCH_LIMIT_DEFAULT = 10;
|
|
6
|
+
const TEXT_CAP = 2000;
|
|
7
|
+
export const SITE = 'https://vargov.ru';
|
|
8
|
+
/** Hosts of the configurator: the Russian interface lives on the Russian copy, every other language on vargov.design
|
|
9
|
+
* (docs/ssylka-i-tekst-dlya-tz.md of the configurator, section 4; the knowledge base links them the same way). */
|
|
10
|
+
export const CONFIGURATOR_RU = 'https://configurator.vargov.ru/';
|
|
11
|
+
export const CONFIGURATOR_INTL = 'https://vargov.design/';
|
|
12
|
+
export function cap(s, n = TEXT_CAP) {
|
|
13
|
+
if (!s)
|
|
14
|
+
return undefined;
|
|
15
|
+
return s.length > n ? s.slice(0, n - 1).trimEnd() + '…' : s;
|
|
16
|
+
}
|
|
17
|
+
export function sitePage(code, lang = 'en') {
|
|
18
|
+
const slug = code.toLowerCase();
|
|
19
|
+
return lang === 'ru' ? `${SITE}/catalog/${slug}` : `${SITE}/${lang}/catalog/${slug}`;
|
|
20
|
+
}
|
|
21
|
+
const CODE_RE = /^lc\d{4}(-\d)?$/i;
|
|
22
|
+
function tokens(q) {
|
|
23
|
+
return q
|
|
24
|
+
.toLowerCase()
|
|
25
|
+
.normalize('NFC')
|
|
26
|
+
.split(/[^\p{L}\p{N}-]+/u)
|
|
27
|
+
.map((t) => t.replace(/^-+|-+$/g, ''))
|
|
28
|
+
.filter((t) => t.length >= 2);
|
|
29
|
+
}
|
|
30
|
+
const esc = (s) => s.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
31
|
+
const WORD_START = '(?:^|[^\\p{L}\\p{N}])';
|
|
32
|
+
const WORD_END = '(?=$|[^\\p{L}\\p{N}])';
|
|
33
|
+
/**
|
|
34
|
+
* Word-level matching with a light stem tolerance:
|
|
35
|
+
* - short tokens (< 5 letters) match whole words only ("spa" does not find "space");
|
|
36
|
+
* - longer tokens match the start of a word ("lobby" finds "lobbies"), and so do their stems
|
|
37
|
+
* minus one letter (≥ 5) and minus two letters (≥ 7): "гостиная" finds "гостиной".
|
|
38
|
+
*/
|
|
39
|
+
function compileToken(t) {
|
|
40
|
+
const isCode = CODE_RE.test(t) || /^\d{4}$/.test(t);
|
|
41
|
+
if (isCode)
|
|
42
|
+
return { raw: t, code: normalizeCode(t), res: [] };
|
|
43
|
+
const res = [];
|
|
44
|
+
if (t.length < 5)
|
|
45
|
+
res.push(new RegExp(WORD_START + esc(t) + WORD_END, 'u'));
|
|
46
|
+
else {
|
|
47
|
+
res.push(new RegExp(WORD_START + esc(t), 'u'));
|
|
48
|
+
res.push(new RegExp(WORD_START + esc(t.slice(0, -1)), 'u'));
|
|
49
|
+
if (t.length >= 7)
|
|
50
|
+
res.push(new RegExp(WORD_START + esc(t.slice(0, -2)), 'u'));
|
|
51
|
+
}
|
|
52
|
+
return { raw: t, code: null, res };
|
|
53
|
+
}
|
|
54
|
+
function hit(field, tok) {
|
|
55
|
+
if (!field)
|
|
56
|
+
return false;
|
|
57
|
+
for (const re of tok.res)
|
|
58
|
+
if (re.test(field))
|
|
59
|
+
return true;
|
|
60
|
+
return false;
|
|
61
|
+
}
|
|
62
|
+
function scoreEntry(e, toks) {
|
|
63
|
+
let score = 0;
|
|
64
|
+
let matched = 0;
|
|
65
|
+
for (const t of toks) {
|
|
66
|
+
let s = 0;
|
|
67
|
+
if (t.code) {
|
|
68
|
+
// a code token matches codes only — no tolerance, or "LC0564" would bring every LC05xx
|
|
69
|
+
if (e.code === t.code)
|
|
70
|
+
s += 1000;
|
|
71
|
+
else if (e.code.startsWith(t.code))
|
|
72
|
+
s += 500; // LC0543 also brings LC0543-1, LC0543-2
|
|
73
|
+
if (s > 0)
|
|
74
|
+
matched++;
|
|
75
|
+
score += s;
|
|
76
|
+
continue;
|
|
77
|
+
}
|
|
78
|
+
if (hit(e.f.code, t))
|
|
79
|
+
s += 100;
|
|
80
|
+
if (hit(e.f.type, t))
|
|
81
|
+
s += 10;
|
|
82
|
+
if (hit(e.f.where, t))
|
|
83
|
+
s += 5;
|
|
84
|
+
if (hit(e.f.style, t))
|
|
85
|
+
s += 3;
|
|
86
|
+
if (hit(e.f.desc, t))
|
|
87
|
+
s += 1;
|
|
88
|
+
if (s === 0 && hit(e.f.other, t))
|
|
89
|
+
s += 1;
|
|
90
|
+
if (s > 0)
|
|
91
|
+
matched++;
|
|
92
|
+
score += s;
|
|
93
|
+
}
|
|
94
|
+
return { score, matched };
|
|
95
|
+
}
|
|
96
|
+
export function searchCompositions(params) {
|
|
97
|
+
const d = getData();
|
|
98
|
+
const limit = Math.max(1, Math.min(SEARCH_LIMIT_MAX, Math.floor(params.limit ?? SEARCH_LIMIT_DEFAULT)));
|
|
99
|
+
const toks = tokens(params.query ?? '').map(compileToken);
|
|
100
|
+
let pool = d.entries.filter((e) => {
|
|
101
|
+
if (params.family && e.p.category !== params.family)
|
|
102
|
+
return false;
|
|
103
|
+
if (params.lit !== undefined && e.lit !== params.lit)
|
|
104
|
+
return false;
|
|
105
|
+
if (params.awarded !== undefined && e.p.award_winning !== params.awarded)
|
|
106
|
+
return false;
|
|
107
|
+
if (params.configurable !== undefined && e.configurable !== params.configurable)
|
|
108
|
+
return false;
|
|
109
|
+
return true;
|
|
110
|
+
});
|
|
111
|
+
let note;
|
|
112
|
+
let scored;
|
|
113
|
+
if (toks.length === 0) {
|
|
114
|
+
scored = pool.map((e) => ({ e, score: 0 }));
|
|
115
|
+
}
|
|
116
|
+
else {
|
|
117
|
+
const all = pool.map((e) => ({ e, ...scoreEntry(e, toks) }));
|
|
118
|
+
let kept = all.filter((x) => x.matched === toks.length && x.score > 0);
|
|
119
|
+
if (kept.length === 0) {
|
|
120
|
+
kept = all.filter((x) => x.score > 0);
|
|
121
|
+
if (kept.length > 0)
|
|
122
|
+
note = 'No composition matched every word of the query; showing compositions that match some of them.';
|
|
123
|
+
}
|
|
124
|
+
scored = kept;
|
|
125
|
+
}
|
|
126
|
+
scored.sort((a, b) => b.score - a.score || Number(b.e.p.award_winning) - Number(a.e.p.award_winning) || a.e.code.localeCompare(b.e.code));
|
|
127
|
+
const results = scored.slice(0, limit).map(({ e }) => toRow(e));
|
|
128
|
+
return { total_matches: scored.length, shown: results.length, results, ...(note ? { note } : {}) };
|
|
129
|
+
}
|
|
130
|
+
function toRow(e) {
|
|
131
|
+
return {
|
|
132
|
+
code: e.code,
|
|
133
|
+
name_en: e.nameEn,
|
|
134
|
+
name_ru: e.nameRu,
|
|
135
|
+
family: e.p.category,
|
|
136
|
+
type_en: e.p.type?.en ?? '',
|
|
137
|
+
configurable: e.configurable,
|
|
138
|
+
kind: e.kind,
|
|
139
|
+
awarded: e.p.award_winning,
|
|
140
|
+
lit_hint: e.lit,
|
|
141
|
+
page_en: e.p.urls?.en ?? sitePage(e.code, 'en'),
|
|
142
|
+
page_ru: e.p.urls?.ru ?? sitePage(e.code, 'ru'),
|
|
143
|
+
image: e.p.image,
|
|
144
|
+
snippet_en: cap(e.p.snippet?.en, 200),
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
// ---------------------------------------------------------------------------------------------
|
|
148
|
+
// get_composition
|
|
149
|
+
export function findEntry(codeInput) {
|
|
150
|
+
return getData().byCode.get(normalizeCode(codeInput)) ?? null;
|
|
151
|
+
}
|
|
152
|
+
export function mountSchemeNote(kind) {
|
|
153
|
+
switch (kind) {
|
|
154
|
+
case 'ribbon':
|
|
155
|
+
return 'No 1:1 ceiling drawing: a ribbon has no cloud of elements; it is built differently.';
|
|
156
|
+
case 'frame':
|
|
157
|
+
return 'No 1:1 ceiling drawing: the elements have no strands of their own to the ceiling — they hang from the frame, and the frame itself is suspended from the ceiling; the IFC4 file records the number of frame suspensions (property SuspensionCount) but not their coordinates, and the suspension points themselves are shown on the frame drawing and on the side view in the configurator.';
|
|
158
|
+
case 'ready-scene':
|
|
159
|
+
return 'No 1:1 ceiling drawing: it is a wall sconce — the composition is ready-made rather than calculated, so there is no layout and no ceiling setting-out; the IFC4 file has no ceiling fixing points.';
|
|
160
|
+
default:
|
|
161
|
+
return null;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
export function hasMountScheme(kind) {
|
|
165
|
+
return kind === 'cloud' || kind === 'chain';
|
|
166
|
+
}
|
|
167
|
+
export function kindNotes(code, kind) {
|
|
168
|
+
const notes = [];
|
|
169
|
+
if (kind === 'ribbon')
|
|
170
|
+
notes.push('Ribbon: the plan Length/Width and the composition height are read from the link; the ribbon shape (wave/spiral) is chosen in the configurator; the FBX export button of a ribbon is in the ribbon panel.');
|
|
171
|
+
if (kind === 'chain')
|
|
172
|
+
notes.push('Chain composition: the form card has no effect on the assembly — the configurator lays the chain out with its own engine.');
|
|
173
|
+
if (kind === 'frame')
|
|
174
|
+
notes.push('Composition on a load-bearing frame: the number of elements is computed by the configurator from the frame pitch and length and cannot be typed by hand.');
|
|
175
|
+
if (kind === 'ready-scene')
|
|
176
|
+
notes.push('Ready scene: the composition opens as its own 3D model; plan dimensions in the link are replaced by the size of the piece; there is no ceiling-height field: the IFC4 model is placed under a 2,700 mm ceiling (the default), and the file does not declare that height as a property.');
|
|
177
|
+
if (code === 'LC0106')
|
|
178
|
+
notes.push('LC0106: instead of plan dimensions the configurator takes the number of jellyfish and the gap between them (link keys jelly and jgap); w/l/h in the link are not used for this composition.');
|
|
179
|
+
return notes;
|
|
180
|
+
}
|
|
181
|
+
export function compositionCard(codeInput, lang = 'en') {
|
|
182
|
+
const d = getData();
|
|
183
|
+
const e = findEntry(codeInput);
|
|
184
|
+
if (!e)
|
|
185
|
+
return null;
|
|
186
|
+
const p = e.p;
|
|
187
|
+
const L = LANGS.includes(lang) ? lang : 'en';
|
|
188
|
+
const sk = d.sketchfab.get(e.code);
|
|
189
|
+
const configurator = e.configurable
|
|
190
|
+
? {
|
|
191
|
+
opens_with_full_calculation: true,
|
|
192
|
+
kind: e.kind,
|
|
193
|
+
exports: ['IFC4 model (BIM)', 'FBX model (3ds Max)', 'PDF specification', 'tender sheet'],
|
|
194
|
+
mount_scheme_1to1: hasMountScheme(e.kind),
|
|
195
|
+
...(mountSchemeNote(e.kind) ? { mount_scheme_1to1_note: mountSchemeNote(e.kind) } : {}),
|
|
196
|
+
// element_size_series_mm (ряды размеров элементов из open-skus.json) снят 27.10.2026 до слова владельца:
|
|
197
|
+
// правило бренда «размеры не называть» — решение за ним, вернуть можно, восстановив этот блок из истории.
|
|
198
|
+
...(d.open.mixPairs?.[e.code] ? { paired_with: d.open.mixPairs[e.code] } : {}),
|
|
199
|
+
link_en: linkUrl(e.code, 'en'),
|
|
200
|
+
link_ru: linkUrl(e.code, 'ru'),
|
|
201
|
+
notes: kindNotes(e.code, e.kind),
|
|
202
|
+
how_to_get_bim: 'call how_to_get_bim with this code',
|
|
203
|
+
}
|
|
204
|
+
: {
|
|
205
|
+
opens_with_full_calculation: false,
|
|
206
|
+
note: 'Calculated individually: the configurator does not calculate this composition, so it has no IFC4/FBX export, no PDF specification from the configurator and no 1:1 ceiling drawing. The link below opens the configurator showcase without a calculation; the production brief cannot be started for it. Contact the brand for a calculation.',
|
|
207
|
+
link_en: `${CONFIGURATOR_INTL}?sku=${encodeURIComponent(e.code)}&lang=en`,
|
|
208
|
+
link_ru: `${CONFIGURATOR_RU}?sku=${encodeURIComponent(e.code)}&lang=ru`,
|
|
209
|
+
};
|
|
210
|
+
const otherType = L !== 'ru' && L !== 'en' && p.type?.[L] ? { [L]: p.type[L] } : {};
|
|
211
|
+
return {
|
|
212
|
+
code: e.code,
|
|
213
|
+
name: { ru: e.nameRu, en: e.nameEn },
|
|
214
|
+
family: p.category,
|
|
215
|
+
family_label: p.category_label,
|
|
216
|
+
type: { ru: p.type?.ru, en: p.type?.en, ...otherType },
|
|
217
|
+
lit_hint: e.lit,
|
|
218
|
+
pages: p.urls,
|
|
219
|
+
image: p.image,
|
|
220
|
+
gallery_images: p.gallery_total,
|
|
221
|
+
texts: {
|
|
222
|
+
lang: L,
|
|
223
|
+
description: cap(p.description?.[L] ?? p.description?.en),
|
|
224
|
+
where_it_works: cap(p.where_it_works?.[L] ?? p.where_it_works?.en),
|
|
225
|
+
style: cap(p.style?.[L] ?? p.style?.en),
|
|
226
|
+
made_to_order: cap(p.made_to_order?.[L] ?? p.made_to_order?.en),
|
|
227
|
+
},
|
|
228
|
+
models_3d: {
|
|
229
|
+
...(p.model3d ? { '3ddd_ru': p.model3d } : {}),
|
|
230
|
+
...(p.model3d_en ? { '3dsky_en': p.model3d_en } : {}),
|
|
231
|
+
...(p.models_all ? { all_models_3ddd: p.models_all } : {}),
|
|
232
|
+
...(p.models_all_en ? { all_models_3dsky: p.models_all_en } : {}),
|
|
233
|
+
...(sk ? { sketchfab: { url: sk.url, published_models_of_this_code: sk.count } } : {}),
|
|
234
|
+
},
|
|
235
|
+
awards: {
|
|
236
|
+
award_winning: p.award_winning,
|
|
237
|
+
list: (p.awards ?? []).map((a) => ({ program: a.program_en ?? a.program, year: a.year, level_en: a.level_en, level_ru: a.level_ru, source: a.href })),
|
|
238
|
+
},
|
|
239
|
+
certification: {
|
|
240
|
+
certified: p.cert !== null && p.cert !== undefined,
|
|
241
|
+
note: p.cert
|
|
242
|
+
? 'Covered by the brand\'s EAEU serial certification (every unit of the article, not a batch). Details: https://vargov.ru/en/certification'
|
|
243
|
+
: 'Not in the list of certified articles of the dataset snapshot. Details: https://vargov.ru/en/certification',
|
|
244
|
+
},
|
|
245
|
+
configurator,
|
|
246
|
+
elements_in_stock: 'Stock changes four times a day; see https://vargov.ru/en/in-stock',
|
|
247
|
+
not_published: 'No price, no materials and no composition dimensions are published: every composition is made to order and scaled to the room. Quotes come per request (info@vargov.ru, WhatsApp +7 916 537 33 52, Telegram @AntonVargov).',
|
|
248
|
+
supply_and_installation: dealerRouteLine('en'),
|
|
249
|
+
};
|
|
250
|
+
}
|
|
251
|
+
/** The configurator does not build a plan smaller than 300 × 300 mm (link-keys contract, memory of the configurator's author, 25.09.2026). */
|
|
252
|
+
export const PLAN_MIN_MM = 300;
|
|
253
|
+
/** Sanity ceiling of this server, not a rule of the configurator. */
|
|
254
|
+
const MM_SANITY_MAX = 50_000;
|
|
255
|
+
function intMm(name, v, min) {
|
|
256
|
+
if (v === undefined || v === null)
|
|
257
|
+
return undefined;
|
|
258
|
+
if (!Number.isFinite(v) || !Number.isInteger(v))
|
|
259
|
+
return { error: `${name} must be an integer number of millimetres (the configurator reads integer mm only)` };
|
|
260
|
+
if (v < min)
|
|
261
|
+
return { error: `${name} must be at least ${min} mm` + (min === PLAN_MIN_MM ? ' — the configurator does not build a plan smaller than 300 × 300 mm' : '') };
|
|
262
|
+
if (v > MM_SANITY_MAX)
|
|
263
|
+
return { error: `${name} exceeds ${MM_SANITY_MAX} mm — check the units (millimetres expected)` };
|
|
264
|
+
return v;
|
|
265
|
+
}
|
|
266
|
+
export function buildConfiguratorLink(params) {
|
|
267
|
+
const d = getData();
|
|
268
|
+
const code = normalizeCode(params.code);
|
|
269
|
+
const e = d.byCode.get(code);
|
|
270
|
+
const lang = params.lang && LANGS.includes(params.lang) ? params.lang : 'en';
|
|
271
|
+
if (!d.openSet.has(code)) {
|
|
272
|
+
return {
|
|
273
|
+
error: e
|
|
274
|
+
? `${code} is calculated individually: the configurator does not open it with a calculation (360 of 605 compositions do). A link with ?sku=${code} would only open the showcase. Use the product page and contact the brand for a calculation.`
|
|
275
|
+
: `${code} is not a code of the Vargov®Design catalogue (LC0001…LC0602, some with a -1/-2 suffix). Use search_compositions to find the code.`,
|
|
276
|
+
code,
|
|
277
|
+
...(e ? { product_page: e.p.urls?.[lang] ?? sitePage(code, lang) } : {}),
|
|
278
|
+
};
|
|
279
|
+
}
|
|
280
|
+
const w = intMm('lengthMm', params.lengthMm, PLAN_MIN_MM);
|
|
281
|
+
const l = intMm('widthMm', params.widthMm, PLAN_MIN_MM);
|
|
282
|
+
const h = intMm('heightMm', params.heightMm, 1);
|
|
283
|
+
const ceil = intMm('ceilingMm', params.ceilingMm, 1);
|
|
284
|
+
for (const v of [w, l, h, ceil])
|
|
285
|
+
if (v && typeof v === 'object')
|
|
286
|
+
return v;
|
|
287
|
+
const q = new URLSearchParams();
|
|
288
|
+
const keys = {};
|
|
289
|
+
q.set('sku', code);
|
|
290
|
+
keys.sku = 'article code';
|
|
291
|
+
if (typeof w === 'number') {
|
|
292
|
+
q.set('w', String(w));
|
|
293
|
+
keys.w = 'the "Length" field of the plan, mm (the letter is misleading: w = Length)';
|
|
294
|
+
}
|
|
295
|
+
if (typeof l === 'number') {
|
|
296
|
+
q.set('l', String(l));
|
|
297
|
+
keys.l = 'the "Width" field of the plan, mm (l = Width)';
|
|
298
|
+
}
|
|
299
|
+
if (typeof h === 'number') {
|
|
300
|
+
q.set('h', String(h));
|
|
301
|
+
keys.h = 'height of the cloud of elements, mm (for a ribbon: the composition height)';
|
|
302
|
+
}
|
|
303
|
+
if (typeof ceil === 'number') {
|
|
304
|
+
q.set('ceil', String(ceil));
|
|
305
|
+
keys.ceil = 'room ceiling height, mm (default 2700): goes into the IFC4 file and AR, does not change the layout';
|
|
306
|
+
}
|
|
307
|
+
q.set('lang', lang);
|
|
308
|
+
keys.lang = 'interface language';
|
|
309
|
+
if (params.openOnFormStep) {
|
|
310
|
+
q.set('step', 'form');
|
|
311
|
+
keys.step = 'form — opens the page scrolled to the "Composition form" step';
|
|
312
|
+
}
|
|
313
|
+
const host = lang === 'ru' ? CONFIGURATOR_RU : CONFIGURATOR_INTL;
|
|
314
|
+
const notes = [
|
|
315
|
+
lang === 'ru'
|
|
316
|
+
? 'Russian interface: the Russian copy configurator.vargov.ru; the same query works on vargov.design.'
|
|
317
|
+
: 'Visitors from Russia are redirected from vargov.design to configurator.vargov.ru with the same query.',
|
|
318
|
+
'All dimensions are integer millimetres. The plan Length × Width is the zone the composition is laid out in, not a product size; the composition is scaled to it.',
|
|
319
|
+
'Element sizes, colours and the composition form are chosen in the configurator; its "Share" button then copies a link that reopens the exact same calculation (the address bar does not reflect the state).',
|
|
320
|
+
...kindNotes(code, d.byCode.get(code)?.kind ?? null),
|
|
321
|
+
];
|
|
322
|
+
return { url: host + '?' + q.toString(), code, lang, keys, notes };
|
|
323
|
+
}
|
|
324
|
+
export function isLinkError(x) {
|
|
325
|
+
return !!x && typeof x === 'object' && 'error' in x;
|
|
326
|
+
}
|
|
327
|
+
function linkUrl(code, lang) {
|
|
328
|
+
const r = buildConfiguratorLink({ code, lang });
|
|
329
|
+
return isLinkError(r) ? null : r.url;
|
|
330
|
+
}
|
|
331
|
+
export { FAMILIES };
|
package/dist/data.js
ADDED
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
// Loads the bundled data (./data) once and builds the indexes the tools use.
|
|
2
|
+
// The server never reads the network: every fact comes from these files.
|
|
3
|
+
import { existsSync, readFileSync } from 'node:fs';
|
|
4
|
+
import { dirname, join } from 'node:path';
|
|
5
|
+
import { fileURLToPath } from 'node:url';
|
|
6
|
+
const here = dirname(fileURLToPath(import.meta.url)); // dist/
|
|
7
|
+
export const DATA_DIR = join(here, '..', 'data');
|
|
8
|
+
export const LANGS = ['ru', 'en', 'de', 'it', 'fr', 'es', 'vi', 'ar'];
|
|
9
|
+
export const FAMILIES = ['lighting', 'decorative', 'sculptural-decor', 'floor-table-lamps'];
|
|
10
|
+
/**
|
|
11
|
+
* Ready scenes: compositions that open in the configurator as a ready-made 3D model, not as a
|
|
12
|
+
* calculated cloud of elements. Since 26.10.2026 the configurator publishes them in open-skus.json as `scenes`
|
|
13
|
+
* (source: scene3d in its model data); this constant is only the fallback for an older open-skus.json without the field.
|
|
14
|
+
* Before that field existed the public sources named one:
|
|
15
|
+
* - en/llms.txt and knowledge/whats-new-2026-10.md (vargov-ai-kb): "the ready scene LC0406-1 — a wall light
|
|
16
|
+
* whose composition is ready-made rather than calculated, so there is no layout and no ceiling setting-out";
|
|
17
|
+
* - open-skus.json `rule`: "ready-made pieces shown as their own 3D model, e.g. the LC0406-1 wall sconce".
|
|
18
|
+
* The 1:1 drawing count published by the brand (345 of 360) = 360 − 10 ribbons − 4 frames − this 1 ready scene;
|
|
19
|
+
* test/smoke.mjs checks that equation against the bundled data.
|
|
20
|
+
*/
|
|
21
|
+
const READY_SCENES = ['LC0406-1'];
|
|
22
|
+
function readText(name) {
|
|
23
|
+
const file = join(DATA_DIR, name);
|
|
24
|
+
return existsSync(file) ? readFileSync(file, 'utf8') : null;
|
|
25
|
+
}
|
|
26
|
+
function readJson(name, required) {
|
|
27
|
+
const txt = readText(name);
|
|
28
|
+
if (txt === null) {
|
|
29
|
+
if (required)
|
|
30
|
+
throw new Error(`vargov-mcp: required data file missing: ${join(DATA_DIR, name)} — run "npm run update-data"`);
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
return JSON.parse(txt);
|
|
34
|
+
}
|
|
35
|
+
/** Normalises user input to the catalogue code form: "lc0564" → "LC0564", " LC 0406-1 " → "LC0406-1", "564" → "LC0564". */
|
|
36
|
+
export function normalizeCode(input) {
|
|
37
|
+
let s = String(input ?? '').trim().toUpperCase().replace(/\s+/g, '');
|
|
38
|
+
if (/^\d{1,4}(-\d)?$/.test(s)) {
|
|
39
|
+
const [num, suffix] = s.split('-');
|
|
40
|
+
s = 'LC' + num.padStart(4, '0') + (suffix ? '-' + suffix : '');
|
|
41
|
+
}
|
|
42
|
+
return s;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* `lit` is a hint derived from public labels, not a measured property:
|
|
46
|
+
* true for the "lighting" family and for any type label that mentions light / lamp / backlit / luminaire.
|
|
47
|
+
*/
|
|
48
|
+
export function isLit(p) {
|
|
49
|
+
if (p.category === 'lighting')
|
|
50
|
+
return true;
|
|
51
|
+
return /\b(light|lamp|backlit|luminaire|illuminat)/i.test(p.type?.en ?? '');
|
|
52
|
+
}
|
|
53
|
+
function lower(s) {
|
|
54
|
+
return typeof s === 'string' ? s.toLowerCase().normalize('NFC') : '';
|
|
55
|
+
}
|
|
56
|
+
function joinLangs(rec, langs) {
|
|
57
|
+
if (!rec)
|
|
58
|
+
return '';
|
|
59
|
+
return langs.map((l) => lower(rec[l])).filter(Boolean).join(' \n ');
|
|
60
|
+
}
|
|
61
|
+
let cached = null;
|
|
62
|
+
export function getData() {
|
|
63
|
+
if (cached)
|
|
64
|
+
return cached;
|
|
65
|
+
const products = readJson('products.json', true);
|
|
66
|
+
const open = readJson('open-skus.json', true);
|
|
67
|
+
const sketchfabRaw = readJson('sketchfab-models.json', false);
|
|
68
|
+
const orgRaw = readJson('organization.jsonld', true);
|
|
69
|
+
const brandFacts = readJson('brand-facts.json', false);
|
|
70
|
+
const manifest = readJson('manifest.json', false);
|
|
71
|
+
const llmsEn = readText('llms-en.txt') ?? '';
|
|
72
|
+
const llmsRu = readText('llms-ru.txt') ?? '';
|
|
73
|
+
const llmsConfigurator = readText('llms-configurator.txt');
|
|
74
|
+
const graph = orgRaw['@graph'] ?? [];
|
|
75
|
+
const pick = (type) => graph.find((n) => n['@type'] === type) ?? null;
|
|
76
|
+
const openSet = new Set(open.skus.map((s) => s.toUpperCase()));
|
|
77
|
+
const ribbons = new Set();
|
|
78
|
+
const chains = new Set();
|
|
79
|
+
for (const [sku, s] of Object.entries(open.series ?? {})) {
|
|
80
|
+
if (s.ribbon)
|
|
81
|
+
ribbons.add(sku.toUpperCase());
|
|
82
|
+
if (s.chain)
|
|
83
|
+
chains.add(sku.toUpperCase());
|
|
84
|
+
}
|
|
85
|
+
const frames = new Set((open.frames ?? []).map((s) => s.toUpperCase()));
|
|
86
|
+
const readyScenes = new Set((open.scenes ?? READY_SCENES).map((s) => s.toUpperCase()).filter((s) => openSet.has(s)));
|
|
87
|
+
const kindOf = (code) => {
|
|
88
|
+
if (!openSet.has(code))
|
|
89
|
+
return null;
|
|
90
|
+
if (ribbons.has(code))
|
|
91
|
+
return 'ribbon';
|
|
92
|
+
if (chains.has(code))
|
|
93
|
+
return 'chain';
|
|
94
|
+
if (frames.has(code))
|
|
95
|
+
return 'frame';
|
|
96
|
+
if (readyScenes.has(code))
|
|
97
|
+
return 'ready-scene';
|
|
98
|
+
return 'cloud';
|
|
99
|
+
};
|
|
100
|
+
const otherLangs = LANGS.filter((l) => l !== 'ru' && l !== 'en');
|
|
101
|
+
const entries = products.map((p) => {
|
|
102
|
+
const code = p.code.toUpperCase();
|
|
103
|
+
return {
|
|
104
|
+
p,
|
|
105
|
+
code,
|
|
106
|
+
nameRu: `${p.type?.ru ?? p.category_label?.ru ?? ''} ${p.code}`.trim(),
|
|
107
|
+
nameEn: `${p.type?.en ?? p.category_label?.en ?? ''} ${p.code}`.trim(),
|
|
108
|
+
lit: isLit(p),
|
|
109
|
+
configurable: openSet.has(code),
|
|
110
|
+
kind: kindOf(code),
|
|
111
|
+
f: {
|
|
112
|
+
code: `${code.toLowerCase()} ${lower(p.slug)}`,
|
|
113
|
+
type: [joinLangs(p.type, LANGS), lower(p.category_label?.ru), lower(p.category_label?.en), lower(p.category)].join(' '),
|
|
114
|
+
where: joinLangs(p.where_it_works, ['ru', 'en']),
|
|
115
|
+
style: joinLangs(p.style, ['ru', 'en']),
|
|
116
|
+
desc: joinLangs(p.description, ['ru', 'en']) + ' ' + joinLangs(p.made_to_order, ['ru', 'en']),
|
|
117
|
+
other: [p.description, p.where_it_works, p.style].map((r) => joinLangs(r, otherLangs)).join(' '),
|
|
118
|
+
},
|
|
119
|
+
};
|
|
120
|
+
});
|
|
121
|
+
const byCode = new Map();
|
|
122
|
+
for (const e of entries)
|
|
123
|
+
byCode.set(e.code, e);
|
|
124
|
+
const sketchfab = new Map();
|
|
125
|
+
for (const [code, item] of Object.entries(sketchfabRaw?.items ?? {}))
|
|
126
|
+
sketchfab.set(code.toUpperCase(), item);
|
|
127
|
+
cached = {
|
|
128
|
+
products,
|
|
129
|
+
entries,
|
|
130
|
+
byCode,
|
|
131
|
+
open,
|
|
132
|
+
openSet,
|
|
133
|
+
ribbons,
|
|
134
|
+
chains,
|
|
135
|
+
frames,
|
|
136
|
+
readyScenes,
|
|
137
|
+
sketchfab,
|
|
138
|
+
organization: pick('Organization'),
|
|
139
|
+
person: pick('Person'),
|
|
140
|
+
store: pick('Store'),
|
|
141
|
+
brandFacts,
|
|
142
|
+
llmsEn,
|
|
143
|
+
llmsRu,
|
|
144
|
+
llmsConfigurator,
|
|
145
|
+
manifest,
|
|
146
|
+
};
|
|
147
|
+
return cached;
|
|
148
|
+
}
|
package/dist/dealers.js
ADDED
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
// dealer_for_country: which official dealer handles supply and installation for a given country.
|
|
2
|
+
//
|
|
3
|
+
// Regions and wording follow the answers published on vargov.ru (FAQ and /official-dealers, Q101, Q102,
|
|
4
|
+
// Q074, Q168; checked 2026-11-19). Dealer phone numbers and e-mails are deliberately NOT bundled: they live
|
|
5
|
+
// on the site's official dealers page only, so an offline copy can never go stale — the answer gives the
|
|
6
|
+
// page and the brand's direct contacts instead.
|
|
7
|
+
import { getData } from './data.js';
|
|
8
|
+
// Same value as catalog.ts SITE; kept local so catalog.ts and bim.ts can import this module without a cycle.
|
|
9
|
+
const SITE = 'https://vargov.ru';
|
|
10
|
+
export const DEALER_REGIONS = [
|
|
11
|
+
{
|
|
12
|
+
id: 'russia-cis',
|
|
13
|
+
city_en: 'Moscow, Russia',
|
|
14
|
+
city_ru: 'Москва, Россия',
|
|
15
|
+
region_en: 'Russia and the CIS',
|
|
16
|
+
region_ru: 'Россия и страны СНГ',
|
|
17
|
+
countries: ['RU', 'BY', 'KZ', 'AM', 'AZ', 'KG', 'MD', 'TJ', 'UZ', 'TM'],
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
id: 'hanoi',
|
|
21
|
+
city_en: 'Hanoi, Vietnam',
|
|
22
|
+
city_ru: 'Ханой, Вьетнам',
|
|
23
|
+
region_en: 'Vietnam, Laos, Cambodia, Thailand, Malaysia and Singapore',
|
|
24
|
+
region_ru: 'Вьетнам, Лаос, Камбоджа, Таиланд, Малайзия и Сингапур',
|
|
25
|
+
countries: ['VN', 'LA', 'KH', 'TH', 'MY', 'SG'],
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
id: 'dubai',
|
|
29
|
+
city_en: 'Dubai, UAE',
|
|
30
|
+
city_ru: 'Дубай, ОАЭ',
|
|
31
|
+
region_en: 'the Persian Gulf, Middle East, Americas, Europe, Asia, Africa and other regions',
|
|
32
|
+
region_ru: 'Персидский залив, Ближний Восток, Америка, Европа, Азия, Африка и другие регионы',
|
|
33
|
+
countries: [],
|
|
34
|
+
},
|
|
35
|
+
];
|
|
36
|
+
// Names people actually type that ICU does not list as a country name.
|
|
37
|
+
const ALIASES = {
|
|
38
|
+
uae: 'AE', emirates: 'AE', 'the emirates': 'AE', dubai: 'AE', 'abu dhabi': 'AE', sharjah: 'AE', 'al ain': 'AE',
|
|
39
|
+
'оаэ': 'AE', 'эмираты': 'AE', 'дубай': 'AE', 'абу-даби': 'AE', 'абу даби': 'AE', 'шарджа': 'AE',
|
|
40
|
+
usa: 'US', 'u.s.': 'US', 'u.s.a.': 'US', america: 'US', 'сша': 'US', 'америка': 'US',
|
|
41
|
+
uk: 'GB', britain: 'GB', 'great britain': 'GB', england: 'GB', 'англия': 'GB', 'великобритания': 'GB',
|
|
42
|
+
russia: 'RU', 'russian federation': 'RU', moscow: 'RU', 'saint petersburg': 'RU', 'st petersburg': 'RU',
|
|
43
|
+
'рф': 'RU', 'москва': 'RU', 'санкт-петербург': 'RU', 'петербург': 'RU', 'казань': 'RU', 'сочи': 'RU',
|
|
44
|
+
hanoi: 'VN', 'ho chi minh city': 'VN', saigon: 'VN', 'ханой': 'VN', 'хошимин': 'VN',
|
|
45
|
+
ksa: 'SA', riyadh: 'SA', jeddah: 'SA', 'эр-рияд': 'SA', doha: 'QA', 'доха': 'QA', muscat: 'OM', 'маскат': 'OM',
|
|
46
|
+
bangkok: 'TH', 'бангкок': 'TH', 'kuala lumpur': 'MY', 'куала-лумпур': 'MY', almaty: 'KZ', astana: 'KZ', minsk: 'BY',
|
|
47
|
+
'алматы': 'KZ', 'астана': 'KZ', 'минск': 'BY', 'ташкент': 'UZ', tashkent: 'UZ', baku: 'AZ', 'баку': 'AZ', yerevan: 'AM', 'ереван': 'AM',
|
|
48
|
+
};
|
|
49
|
+
// Codes Intl.DisplayNames knows that are not countries.
|
|
50
|
+
const NOT_COUNTRIES = new Set(['EU', 'EZ', 'UN', 'ZZ', 'QO', 'XA', 'XB']);
|
|
51
|
+
function norm(s) {
|
|
52
|
+
return s
|
|
53
|
+
.toLowerCase()
|
|
54
|
+
.replace(/ё/g, 'е')
|
|
55
|
+
.replace(/[«»"'’().,]/g, ' ')
|
|
56
|
+
.replace(/\s+/g, ' ')
|
|
57
|
+
.trim();
|
|
58
|
+
}
|
|
59
|
+
let nameIndex = null;
|
|
60
|
+
/** name (English or Russian, as ICU spells it) → ISO code, built once from Intl.DisplayNames. */
|
|
61
|
+
function names() {
|
|
62
|
+
if (nameIndex)
|
|
63
|
+
return nameIndex;
|
|
64
|
+
const idx = new Map();
|
|
65
|
+
const letters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
|
|
66
|
+
for (const loc of ['en', 'ru']) {
|
|
67
|
+
let dn;
|
|
68
|
+
try {
|
|
69
|
+
dn = new Intl.DisplayNames([loc], { type: 'region' });
|
|
70
|
+
}
|
|
71
|
+
catch {
|
|
72
|
+
continue;
|
|
73
|
+
}
|
|
74
|
+
for (const a of letters)
|
|
75
|
+
for (const b of letters) {
|
|
76
|
+
const code = a + b;
|
|
77
|
+
if (NOT_COUNTRIES.has(code))
|
|
78
|
+
continue;
|
|
79
|
+
let name;
|
|
80
|
+
try {
|
|
81
|
+
name = dn.of(code);
|
|
82
|
+
}
|
|
83
|
+
catch {
|
|
84
|
+
continue;
|
|
85
|
+
}
|
|
86
|
+
if (!name || name === code || /unknown region|неизвестный регион/i.test(name))
|
|
87
|
+
continue;
|
|
88
|
+
idx.set(norm(name), code);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
for (const [k, v] of Object.entries(ALIASES))
|
|
92
|
+
idx.set(norm(k), v);
|
|
93
|
+
nameIndex = idx;
|
|
94
|
+
return idx;
|
|
95
|
+
}
|
|
96
|
+
/** ISO alpha-2 code for a country name, ISO code or a major city; null when not recognised. */
|
|
97
|
+
export function countryCode(input) {
|
|
98
|
+
const raw = input.trim();
|
|
99
|
+
if (!raw)
|
|
100
|
+
return null;
|
|
101
|
+
const idx = names();
|
|
102
|
+
if (/^[A-Za-z]{2}$/.test(raw)) {
|
|
103
|
+
const code = raw.toUpperCase();
|
|
104
|
+
return [...idx.values()].includes(code) ? code : null;
|
|
105
|
+
}
|
|
106
|
+
return idx.get(norm(raw)) ?? null;
|
|
107
|
+
}
|
|
108
|
+
function regionFor(code) {
|
|
109
|
+
return DEALER_REGIONS.find((r) => r.countries.includes(code)) ?? DEALER_REGIONS.find((r) => r.id === 'dubai');
|
|
110
|
+
}
|
|
111
|
+
function brandContacts() {
|
|
112
|
+
const org = getData().organization;
|
|
113
|
+
return {
|
|
114
|
+
email: org?.email ?? 'info@vargov.ru',
|
|
115
|
+
whatsapp: org?.telephone ?? '+7 916 537 33 52',
|
|
116
|
+
telegram: 'https://t.me/AntonVargov',
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
export function dealerForCountry(country, lang = 'en') {
|
|
120
|
+
const ru = lang === 'ru';
|
|
121
|
+
const page = ru ? `${SITE}/official-dealers` : `${SITE}/en/official-dealers`;
|
|
122
|
+
const regions = DEALER_REGIONS.map((r) => ({
|
|
123
|
+
id: r.id,
|
|
124
|
+
dealer_city: ru ? r.city_ru : r.city_en,
|
|
125
|
+
region: ru ? r.region_ru : r.region_en,
|
|
126
|
+
}));
|
|
127
|
+
const common = {
|
|
128
|
+
who_supplies_and_installs: ru
|
|
129
|
+
? 'Три официальных дилера, каждый отвечает за поставку, монтаж и обслуживание композиций в своём регионе. Монтаж силами официальных монтажных партнёров — отдельная услуга, стоимость рассчитывается индивидуально; можно заказать и шеф-монтаж.'
|
|
130
|
+
: 'Three official dealers, each responsible for supply, installation and servicing of the compositions in its region. Installation by the official installation partners is a separate service, priced individually; supervised installation can also be ordered.',
|
|
131
|
+
dealer_contacts_page: page,
|
|
132
|
+
brand_direct_contacts: brandContacts(),
|
|
133
|
+
regions,
|
|
134
|
+
source: ru ? `${SITE}/faq` : `${SITE}/en/faq`,
|
|
135
|
+
};
|
|
136
|
+
const code = country ? countryCode(country) : null;
|
|
137
|
+
if (!country)
|
|
138
|
+
return { country: null, recommended: null, ...common };
|
|
139
|
+
if (!code) {
|
|
140
|
+
return {
|
|
141
|
+
country,
|
|
142
|
+
recommended: null,
|
|
143
|
+
note: ru
|
|
144
|
+
? `Страну «${country}» не удалось распознать. Выберите регион из списка ниже; Дубай отвечает за все страны, не названные в двух других регионах.`
|
|
145
|
+
: `Could not recognise "${country}" as a country. Pick the region from the list below; Dubai covers every country not named in the other two regions.`,
|
|
146
|
+
...common,
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
const r = regionFor(code);
|
|
150
|
+
const recommended = {
|
|
151
|
+
country_code: code,
|
|
152
|
+
dealer_region_id: r.id,
|
|
153
|
+
dealer_city: ru ? r.city_ru : r.city_en,
|
|
154
|
+
region: ru ? r.region_ru : r.region_en,
|
|
155
|
+
contacts: page,
|
|
156
|
+
orders: r.id === 'dubai'
|
|
157
|
+
? ru
|
|
158
|
+
? 'Заказы по Дубаю и этому региону принимает офис бренда в Дубае; контакты те же, что у дилера.'
|
|
159
|
+
: "Orders for Dubai and this region are accepted by the brand's office in Dubai; the contacts are the dealer's."
|
|
160
|
+
: ru
|
|
161
|
+
? 'Контакты дилера региона — на странице дилеров; с заказом поможет и менеджер бренда (Telegram, WhatsApp, e-mail).'
|
|
162
|
+
: "The regional dealer's contacts are on the dealers page; the brand's manager also helps with the order (Telegram, WhatsApp, e-mail).",
|
|
163
|
+
};
|
|
164
|
+
return { country, recommended, ...common };
|
|
165
|
+
}
|
|
166
|
+
/** One line for texts that send the reader to "contact the brand": the regional dealer route. */
|
|
167
|
+
export function dealerRouteLine(lang) {
|
|
168
|
+
return lang === 'ru'
|
|
169
|
+
? `В России и СНГ, в Персидском заливе и других регионах, во Вьетнаме и соседних странах за поставку и монтаж отвечает официальный дилер региона — контакты на ${SITE}/official-dealers (инструмент dealer_for_country подскажет дилера по стране).`
|
|
170
|
+
: `In Russia and the CIS, in the Persian Gulf and other regions, and in Vietnam and its neighbours, the regional official dealer handles supply and installation — contacts at ${SITE}/en/official-dealers (the dealer_for_country tool names the dealer for a country).`;
|
|
171
|
+
}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Entry point: MCP server over stdio. Nothing but the protocol goes to stdout; diagnostics go to stderr.
|
|
3
|
+
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
4
|
+
import { getData } from './data.js';
|
|
5
|
+
import { SERVER_NAME, SERVER_VERSION, createServer } from './server.js';
|
|
6
|
+
async function main() {
|
|
7
|
+
const d = getData(); // fail fast if data/ is missing
|
|
8
|
+
const server = createServer();
|
|
9
|
+
const transport = new StdioServerTransport();
|
|
10
|
+
await server.connect(transport);
|
|
11
|
+
process.stderr.write(`${SERVER_NAME} ${SERVER_VERSION}: ${d.products.length} compositions, ${d.openSet.size} open in the configurator; stdio ready\n`);
|
|
12
|
+
}
|
|
13
|
+
main().catch((err) => {
|
|
14
|
+
process.stderr.write(`${SERVER_NAME}: fatal: ${err instanceof Error ? err.stack ?? err.message : String(err)}\n`);
|
|
15
|
+
process.exit(1);
|
|
16
|
+
});
|