tdk-api-wrapper 1.6.1 → 1.7.1
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/LICENSE +674 -21
- package/README.md +23 -3
- package/dist/{chunk-ZFWZXNGY.mjs → chunk-YY4WA2AO.mjs} +126 -142
- package/dist/chunk-ZG7YRT7V.mjs +279 -0
- package/dist/cli.js +2489 -2127
- package/dist/cli.mjs +12 -5
- package/dist/index.d.mts +23 -38
- package/dist/index.d.ts +23 -38
- package/dist/index.js +402 -143
- package/dist/index.mjs +8 -2
- package/dist/mcp-GBTXQJLW.mjs +9 -0
- package/package.json +13 -5
package/dist/cli.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
TDK
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-YY4WA2AO.mjs";
|
|
5
5
|
|
|
6
6
|
// src/cli.ts
|
|
7
7
|
var rawArgs = process.argv.slice(2);
|
|
@@ -48,7 +48,8 @@ var KNOWN_COMMANDS = /* @__PURE__ */ new Set([
|
|
|
48
48
|
"repl",
|
|
49
49
|
"kubbealti",
|
|
50
50
|
"nisanyan",
|
|
51
|
-
"viki"
|
|
51
|
+
"viki",
|
|
52
|
+
"mcp"
|
|
52
53
|
]);
|
|
53
54
|
var command = args[0];
|
|
54
55
|
var word = args.slice(1).join(" ");
|
|
@@ -135,6 +136,12 @@ async function startRepl() {
|
|
|
135
136
|
});
|
|
136
137
|
}
|
|
137
138
|
async function run() {
|
|
139
|
+
const binaryName = (process.argv[1] || "").toLowerCase();
|
|
140
|
+
if (command === "mcp" || rawArgs.includes("--mcp") || binaryName.includes("tdk-mcp")) {
|
|
141
|
+
const { runMcpServer } = await import("./mcp-GBTXQJLW.mjs");
|
|
142
|
+
await runMcpServer();
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
138
145
|
if (!command) {
|
|
139
146
|
if (process.stdin.isTTY) {
|
|
140
147
|
await startRepl();
|
|
@@ -142,19 +149,19 @@ async function run() {
|
|
|
142
149
|
}
|
|
143
150
|
console.log("Kullan\u0131m: tdk [komut] <kelime> [--json]");
|
|
144
151
|
console.log(
|
|
145
|
-
"Komutlar: ara, anlam, koken, ornek, hece, uyum, kucukuyum, yazim, kok, deyim, gunun, rastgele, esanlam, karsit, yabanci, kurallar, kural, karsilastir, analiz, oneri, bulmaca, anagram, kafiye, denetle, repl, kubbealti, nisanyan, viki"
|
|
152
|
+
"Komutlar: ara, anlam, koken, ornek, hece, uyum, kucukuyum, yazim, kok, deyim, gunun, rastgele, esanlam, karsit, yabanci, kurallar, kural, karsilastir, analiz, oneri, bulmaca, anagram, kafiye, denetle, repl, kubbealti, nisanyan, viki, mcp"
|
|
146
153
|
);
|
|
147
154
|
console.log("Not: Komut belirtilmezse do\u011Frudan kelime anlam\u0131 aran\u0131r (\xF6rn: tdk selam)");
|
|
148
155
|
process.exit(1);
|
|
149
156
|
}
|
|
150
157
|
if (command === "--version" || command === "-v") {
|
|
151
|
-
console.log("tdk-api-wrapper v1.
|
|
158
|
+
console.log("tdk-api-wrapper v1.7.0");
|
|
152
159
|
process.exit(0);
|
|
153
160
|
}
|
|
154
161
|
if (command === "--help" || command === "-h") {
|
|
155
162
|
console.log("Kullan\u0131m: tdk [komut] <kelime> [--json]");
|
|
156
163
|
console.log(
|
|
157
|
-
"Komutlar: ara, anlam, koken, ornek, hece, uyum, kucukuyum, yazim, kok, deyim, gunun, rastgele, esanlam, karsit, yabanci, kurallar, kural, karsilastir, analiz, oneri, bulmaca, anagram, kafiye, denetle, repl, kubbealti, nisanyan, viki"
|
|
164
|
+
"Komutlar: ara, anlam, koken, ornek, hece, uyum, kucukuyum, yazim, kok, deyim, gunun, rastgele, esanlam, karsit, yabanci, kurallar, kural, karsilastir, analiz, oneri, bulmaca, anagram, kafiye, denetle, repl, kubbealti, nisanyan, viki, mcp"
|
|
158
165
|
);
|
|
159
166
|
console.log("Not: Komut belirtilmezse do\u011Frudan kelime anlam\u0131 aran\u0131r (\xF6rn: tdk selam)");
|
|
160
167
|
process.exit(0);
|
package/dist/index.d.mts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
|
+
|
|
1
3
|
interface Author {
|
|
2
4
|
yazar_id: string;
|
|
3
5
|
tam_adi: string;
|
|
@@ -186,19 +188,6 @@ declare class TDK {
|
|
|
186
188
|
private static readonly BASE_URL;
|
|
187
189
|
private static readonly AUDIO_API_HOST;
|
|
188
190
|
private static readonly KUBBEALTI_HOST;
|
|
189
|
-
/**
|
|
190
|
-
* `eski.lugatim.com` (Kubbealtı Lugatı's data API) sends only its leaf
|
|
191
|
-
* certificate during the TLS handshake, omitting the intermediates a
|
|
192
|
-
* correctly configured server would include — a server-side misconfiguration,
|
|
193
|
-
* not something we should paper over by disabling verification. These are
|
|
194
|
-
* the two certificates the server *should* be sending (fetched from the
|
|
195
|
-
* leaf's own Authority Information Access URLs), supplied here so Node can
|
|
196
|
-
* still build a full, properly verified chain up to a root it already
|
|
197
|
-
* trusts (ISRG Root X1). If Let's Encrypt rotates this intermediate, this
|
|
198
|
-
* stops working and every Kubbealtı call fails closed to `null` — same
|
|
199
|
-
* fail-closed contract as the rest of this file's fragile integrations.
|
|
200
|
-
*/
|
|
201
|
-
private static readonly KUBBEALTI_EXTRA_CA;
|
|
202
191
|
private static defaultTimeoutMs;
|
|
203
192
|
private static defaultRetries;
|
|
204
193
|
private static maxCacheSize;
|
|
@@ -397,7 +386,6 @@ declare class TDK {
|
|
|
397
386
|
* spans) — cutting there avoids that trailing cruft.
|
|
398
387
|
*/
|
|
399
388
|
private static fetchRuleText;
|
|
400
|
-
private static htmlToPlainText;
|
|
401
389
|
/**
|
|
402
390
|
* GETs a JSON path from Kubbealtı Lugatı's data API (`eski.lugatim.com`),
|
|
403
391
|
* supplying `KUBBEALTI_EXTRA_CA` to work around that host's incomplete
|
|
@@ -500,24 +488,6 @@ declare class TDK {
|
|
|
500
488
|
* headword. This is an inherent limitation of the data source, not a bug.
|
|
501
489
|
*/
|
|
502
490
|
static analyzeText(text: string): Promise<WordAnalysis[]>;
|
|
503
|
-
/**
|
|
504
|
-
* Damerau-Levenshtein edit-distance (optimal string alignment variant):
|
|
505
|
-
* like classic Levenshtein but also counts an adjacent-character
|
|
506
|
-
* transposition (e.g. "yanlız" -> "yalnız") as a single edit instead of
|
|
507
|
-
* two substitutions — a very common class of typo that plain Levenshtein
|
|
508
|
-
* otherwise misses.
|
|
509
|
-
*/
|
|
510
|
-
private static damerauLevenshtein;
|
|
511
|
-
/**
|
|
512
|
-
* Keyboard- and diacritic-aware edit distance: same optimal-string-alignment
|
|
513
|
-
* recurrence as {@link damerauLevenshtein}, but a substitution is charged by
|
|
514
|
-
* {@link keyboardSubCost} (a fraction of an edit when the two letters are
|
|
515
|
-
* adjacent on a Turkish Q keyboard or are ASCII/diacritic siblings) and a
|
|
516
|
-
* transposition costs {@link TRANSPOSITION_COST}. Insertions and deletions
|
|
517
|
-
* still cost a full 1. Used only to *rank* spelling candidates; the plain
|
|
518
|
-
* integer distance still gates whether a suggestion is offered at all.
|
|
519
|
-
*/
|
|
520
|
-
private static keyboardAwareDistance;
|
|
521
491
|
/**
|
|
522
492
|
* Fetches multiple words concurrently with a small delay to avoid rate limiting.
|
|
523
493
|
*/
|
|
@@ -621,6 +591,13 @@ declare class TDKNetworkError extends TDKError {
|
|
|
621
591
|
});
|
|
622
592
|
}
|
|
623
593
|
|
|
594
|
+
/**
|
|
595
|
+
* Turkish suffix catalogue used by the morphology engine's BFS stem-stripper
|
|
596
|
+
* (see `morphology.ts`). Ordered strictly by descending length so that
|
|
597
|
+
* longer composite suffixes match before their individual subcomponents.
|
|
598
|
+
*/
|
|
599
|
+
declare const TURKISH_SUFFIXES: readonly string[];
|
|
600
|
+
|
|
624
601
|
/**
|
|
625
602
|
* Turkish Morphology Engine & Stem Candidate Generator.
|
|
626
603
|
*
|
|
@@ -631,13 +608,9 @@ declare class TDKNetworkError extends TDKError {
|
|
|
631
608
|
* 4. Infinitive restoration (-mek / -mak for verbal stems)
|
|
632
609
|
* 5. Apostrophe stripping for proper nouns (İstanbul'da -> İstanbul)
|
|
633
610
|
*/
|
|
611
|
+
|
|
634
612
|
declare const TURKISH_VOWELS = "ae\u0131io\u00F6u\u00FC";
|
|
635
613
|
declare function isVowel(ch: string): boolean;
|
|
636
|
-
/**
|
|
637
|
-
* Turkish suffixes ordered strictly by descending length so that longer
|
|
638
|
-
* composite suffixes match before their individual subcomponents.
|
|
639
|
-
*/
|
|
640
|
-
declare const TURKISH_SUFFIXES: readonly string[];
|
|
641
614
|
/**
|
|
642
615
|
* Reverses Turkish consonant softening (ünsüz yumuşaması):
|
|
643
616
|
* When a root ends with p, ç, t, k, it softens to b, c, d, ğ, g before a vowel.
|
|
@@ -685,4 +658,16 @@ declare function restoreInfinitive(stem: string): string[];
|
|
|
685
658
|
*/
|
|
686
659
|
declare function getStemCandidates(word: string, minStemLength?: number, maxDepth?: number): string[];
|
|
687
660
|
|
|
688
|
-
|
|
661
|
+
/**
|
|
662
|
+
* Builds the TDK MCP server: every meaningful `TDK` static method is surfaced
|
|
663
|
+
* as a Model Context Protocol tool so an LLM client (Claude Desktop, Cursor,
|
|
664
|
+
* Antigravity, …) can query Turkish dictionary, morphology, spelling and
|
|
665
|
+
* etymology data directly. All tools return JSON text; network/scraping
|
|
666
|
+
* failures come back as `{ "error": ... }` with `isError: true` rather than
|
|
667
|
+
* throwing.
|
|
668
|
+
*/
|
|
669
|
+
declare function createMcpServer(): McpServer;
|
|
670
|
+
/** Starts the TDK MCP server over stdio (used by the `tdk mcp` CLI command). */
|
|
671
|
+
declare function runMcpServer(): Promise<void>;
|
|
672
|
+
|
|
673
|
+
export { type AnagramOptions, type Author, type DailyContent, type DailyPick, type Example, type Feature, type KubbealtiEntry, type Meaning, type PatternSearchOptions, type ProofreadIssue, type ProofreadResult, type Proverb, type RhymeOptions, type SpellCheckResult, type StemResult, TDK, TDKClient, type TDKConfig, TDKError, TDKNetworkError, type TDKResponse, type TDKRule, TDKValidationError, TURKISH_SUFFIXES, TURKISH_VOWELS, type WiktionaryEntry, type WordAnalysis, type WordComparison, type WordComparisonSide, type WordInfo, type WordOfTheDay, createMcpServer, getStemCandidates, isVowel, restoreConsonantSoftening, restoreGemination, restoreInfinitive, restoreVowelDrop, restoreVowelNarrowing, runMcpServer };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
|
+
|
|
1
3
|
interface Author {
|
|
2
4
|
yazar_id: string;
|
|
3
5
|
tam_adi: string;
|
|
@@ -186,19 +188,6 @@ declare class TDK {
|
|
|
186
188
|
private static readonly BASE_URL;
|
|
187
189
|
private static readonly AUDIO_API_HOST;
|
|
188
190
|
private static readonly KUBBEALTI_HOST;
|
|
189
|
-
/**
|
|
190
|
-
* `eski.lugatim.com` (Kubbealtı Lugatı's data API) sends only its leaf
|
|
191
|
-
* certificate during the TLS handshake, omitting the intermediates a
|
|
192
|
-
* correctly configured server would include — a server-side misconfiguration,
|
|
193
|
-
* not something we should paper over by disabling verification. These are
|
|
194
|
-
* the two certificates the server *should* be sending (fetched from the
|
|
195
|
-
* leaf's own Authority Information Access URLs), supplied here so Node can
|
|
196
|
-
* still build a full, properly verified chain up to a root it already
|
|
197
|
-
* trusts (ISRG Root X1). If Let's Encrypt rotates this intermediate, this
|
|
198
|
-
* stops working and every Kubbealtı call fails closed to `null` — same
|
|
199
|
-
* fail-closed contract as the rest of this file's fragile integrations.
|
|
200
|
-
*/
|
|
201
|
-
private static readonly KUBBEALTI_EXTRA_CA;
|
|
202
191
|
private static defaultTimeoutMs;
|
|
203
192
|
private static defaultRetries;
|
|
204
193
|
private static maxCacheSize;
|
|
@@ -397,7 +386,6 @@ declare class TDK {
|
|
|
397
386
|
* spans) — cutting there avoids that trailing cruft.
|
|
398
387
|
*/
|
|
399
388
|
private static fetchRuleText;
|
|
400
|
-
private static htmlToPlainText;
|
|
401
389
|
/**
|
|
402
390
|
* GETs a JSON path from Kubbealtı Lugatı's data API (`eski.lugatim.com`),
|
|
403
391
|
* supplying `KUBBEALTI_EXTRA_CA` to work around that host's incomplete
|
|
@@ -500,24 +488,6 @@ declare class TDK {
|
|
|
500
488
|
* headword. This is an inherent limitation of the data source, not a bug.
|
|
501
489
|
*/
|
|
502
490
|
static analyzeText(text: string): Promise<WordAnalysis[]>;
|
|
503
|
-
/**
|
|
504
|
-
* Damerau-Levenshtein edit-distance (optimal string alignment variant):
|
|
505
|
-
* like classic Levenshtein but also counts an adjacent-character
|
|
506
|
-
* transposition (e.g. "yanlız" -> "yalnız") as a single edit instead of
|
|
507
|
-
* two substitutions — a very common class of typo that plain Levenshtein
|
|
508
|
-
* otherwise misses.
|
|
509
|
-
*/
|
|
510
|
-
private static damerauLevenshtein;
|
|
511
|
-
/**
|
|
512
|
-
* Keyboard- and diacritic-aware edit distance: same optimal-string-alignment
|
|
513
|
-
* recurrence as {@link damerauLevenshtein}, but a substitution is charged by
|
|
514
|
-
* {@link keyboardSubCost} (a fraction of an edit when the two letters are
|
|
515
|
-
* adjacent on a Turkish Q keyboard or are ASCII/diacritic siblings) and a
|
|
516
|
-
* transposition costs {@link TRANSPOSITION_COST}. Insertions and deletions
|
|
517
|
-
* still cost a full 1. Used only to *rank* spelling candidates; the plain
|
|
518
|
-
* integer distance still gates whether a suggestion is offered at all.
|
|
519
|
-
*/
|
|
520
|
-
private static keyboardAwareDistance;
|
|
521
491
|
/**
|
|
522
492
|
* Fetches multiple words concurrently with a small delay to avoid rate limiting.
|
|
523
493
|
*/
|
|
@@ -621,6 +591,13 @@ declare class TDKNetworkError extends TDKError {
|
|
|
621
591
|
});
|
|
622
592
|
}
|
|
623
593
|
|
|
594
|
+
/**
|
|
595
|
+
* Turkish suffix catalogue used by the morphology engine's BFS stem-stripper
|
|
596
|
+
* (see `morphology.ts`). Ordered strictly by descending length so that
|
|
597
|
+
* longer composite suffixes match before their individual subcomponents.
|
|
598
|
+
*/
|
|
599
|
+
declare const TURKISH_SUFFIXES: readonly string[];
|
|
600
|
+
|
|
624
601
|
/**
|
|
625
602
|
* Turkish Morphology Engine & Stem Candidate Generator.
|
|
626
603
|
*
|
|
@@ -631,13 +608,9 @@ declare class TDKNetworkError extends TDKError {
|
|
|
631
608
|
* 4. Infinitive restoration (-mek / -mak for verbal stems)
|
|
632
609
|
* 5. Apostrophe stripping for proper nouns (İstanbul'da -> İstanbul)
|
|
633
610
|
*/
|
|
611
|
+
|
|
634
612
|
declare const TURKISH_VOWELS = "ae\u0131io\u00F6u\u00FC";
|
|
635
613
|
declare function isVowel(ch: string): boolean;
|
|
636
|
-
/**
|
|
637
|
-
* Turkish suffixes ordered strictly by descending length so that longer
|
|
638
|
-
* composite suffixes match before their individual subcomponents.
|
|
639
|
-
*/
|
|
640
|
-
declare const TURKISH_SUFFIXES: readonly string[];
|
|
641
614
|
/**
|
|
642
615
|
* Reverses Turkish consonant softening (ünsüz yumuşaması):
|
|
643
616
|
* When a root ends with p, ç, t, k, it softens to b, c, d, ğ, g before a vowel.
|
|
@@ -685,4 +658,16 @@ declare function restoreInfinitive(stem: string): string[];
|
|
|
685
658
|
*/
|
|
686
659
|
declare function getStemCandidates(word: string, minStemLength?: number, maxDepth?: number): string[];
|
|
687
660
|
|
|
688
|
-
|
|
661
|
+
/**
|
|
662
|
+
* Builds the TDK MCP server: every meaningful `TDK` static method is surfaced
|
|
663
|
+
* as a Model Context Protocol tool so an LLM client (Claude Desktop, Cursor,
|
|
664
|
+
* Antigravity, …) can query Turkish dictionary, morphology, spelling and
|
|
665
|
+
* etymology data directly. All tools return JSON text; network/scraping
|
|
666
|
+
* failures come back as `{ "error": ... }` with `isError: true` rather than
|
|
667
|
+
* throwing.
|
|
668
|
+
*/
|
|
669
|
+
declare function createMcpServer(): McpServer;
|
|
670
|
+
/** Starts the TDK MCP server over stdio (used by the `tdk mcp` CLI command). */
|
|
671
|
+
declare function runMcpServer(): Promise<void>;
|
|
672
|
+
|
|
673
|
+
export { type AnagramOptions, type Author, type DailyContent, type DailyPick, type Example, type Feature, type KubbealtiEntry, type Meaning, type PatternSearchOptions, type ProofreadIssue, type ProofreadResult, type Proverb, type RhymeOptions, type SpellCheckResult, type StemResult, TDK, TDKClient, type TDKConfig, TDKError, TDKNetworkError, type TDKResponse, type TDKRule, TDKValidationError, TURKISH_SUFFIXES, TURKISH_VOWELS, type WiktionaryEntry, type WordAnalysis, type WordComparison, type WordComparisonSide, type WordInfo, type WordOfTheDay, createMcpServer, getStemCandidates, isVowel, restoreConsonantSoftening, restoreGemination, restoreInfinitive, restoreVowelDrop, restoreVowelNarrowing, runMcpServer };
|