@hemingweb/wordnook-mcp 1.0.36 → 1.0.37

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.
@@ -384,6 +384,89 @@ var SearchIndex = class {
384
384
  getAllWords() {
385
385
  return this.words;
386
386
  }
387
+ /**
388
+ * Retrieves the immediately preceding and succeeding headwords alphabetically.
389
+ * Enables the dictionary "Before & After" stepper navigation.
390
+ */
391
+ getAdjacentWords(word) {
392
+ const clean = word.trim().toLowerCase();
393
+ if (!clean || this.words.length === 0) return {};
394
+ const idx = this.binarySearch(clean);
395
+ if (idx >= 0) {
396
+ return {
397
+ prev: idx > 0 ? this.words[idx - 1] : void 0,
398
+ next: idx < this.words.length - 1 ? this.words[idx + 1] : void 0
399
+ };
400
+ }
401
+ const ins = -(idx + 1);
402
+ return {
403
+ prev: ins > 0 ? this.words[ins - 1] : void 0,
404
+ next: ins < this.words.length ? this.words[ins] : void 0
405
+ };
406
+ }
407
+ /**
408
+ * Retrieves vocabulary headwords starting with a specific letter or prefix.
409
+ */
410
+ getWordsStartingWith(prefix, limit = 500) {
411
+ const cleanPrefix = prefix.trim().toLowerCase();
412
+ if (!cleanPrefix || this.words.length === 0) return [];
413
+ let low = 0;
414
+ let high = this.words.length - 1;
415
+ let startIdx = -1;
416
+ while (low <= high) {
417
+ const mid = low + high >> 1;
418
+ if (this.words[mid].startsWith(cleanPrefix)) {
419
+ startIdx = mid;
420
+ high = mid - 1;
421
+ } else if (this.words[mid] < cleanPrefix) {
422
+ low = mid + 1;
423
+ } else {
424
+ high = mid - 1;
425
+ }
426
+ }
427
+ if (startIdx === -1) return [];
428
+ const results = [];
429
+ for (let i = startIdx; i < this.words.length && results.length < limit; i++) {
430
+ if (this.words[i].startsWith(cleanPrefix)) {
431
+ results.push(this.words[i]);
432
+ } else {
433
+ break;
434
+ }
435
+ }
436
+ return results;
437
+ }
438
+ /**
439
+ * Retrieves unique two-letter prefixes available for a given initial letter.
440
+ * Enables fine-grained alphabetical sub-navigation (e.g., 'B' -> ['ba', 'be', 'bi', 'bl', ...]).
441
+ */
442
+ getSubPrefixes(letter) {
443
+ const cleanLetter = letter.trim().toLowerCase();
444
+ if (!cleanLetter || this.words.length === 0) return [];
445
+ const prefixSet = /* @__PURE__ */ new Set();
446
+ let low = 0;
447
+ let high = this.words.length - 1;
448
+ let startIdx = -1;
449
+ while (low <= high) {
450
+ const mid = low + high >> 1;
451
+ if (this.words[mid].startsWith(cleanLetter)) {
452
+ startIdx = mid;
453
+ high = mid - 1;
454
+ } else if (this.words[mid] < cleanLetter) {
455
+ low = mid + 1;
456
+ } else {
457
+ high = mid - 1;
458
+ }
459
+ }
460
+ if (startIdx === -1) return [];
461
+ for (let i = startIdx; i < this.words.length; i++) {
462
+ const w = this.words[i];
463
+ if (!w.startsWith(cleanLetter)) break;
464
+ if (w.length >= 2 && /^[a-z]{2}/.test(w)) {
465
+ prefixSet.add(w.slice(0, 2));
466
+ }
467
+ }
468
+ return Array.from(prefixSet).sort();
469
+ }
387
470
  binarySearch(target) {
388
471
  let low = 0;
389
472
  let high = this.words.length - 1;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hemingweb/wordnook-mcp",
3
- "version": "1.0.36",
3
+ "version": "1.0.37",
4
4
  "description": "Offline-first linguistic Model Context Protocol (MCP) server providing dictionaries, thesauruses, and lemmatization for AI agents.",
5
5
  "type": "module",
6
6
  "license": "CC-BY-SA-4.0",