@cachly-dev/mcp-server 0.1.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/CHANGELOG.md +45 -0
- package/README.md +348 -0
- package/dist/__tests__/namespace.test.d.ts +1 -0
- package/dist/__tests__/namespace.test.js +114 -0
- package/dist/__tests__/namespace.test.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2879 -0
- package/dist/index.js.map +1 -0
- package/dist/namespace.d.ts +20 -0
- package/dist/namespace.js +128 -0
- package/dist/namespace.js.map +1 -0
- package/package.json +51 -0
- package/run-mcp.sh +57 -0
- package/src/__tests__/namespace.test.ts +126 -0
- package/src/index.ts +3327 -0
- package/src/namespace.ts +128 -0
- package/tsconfig.json +17 -0
package/src/namespace.ts
ADDED
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Namespace Auto-Detection
|
|
3
|
+
*
|
|
4
|
+
* Classify a prompt into one of 5 semantic namespaces using text heuristics.
|
|
5
|
+
* Overhead: <0.1 ms. No embedding required.
|
|
6
|
+
*
|
|
7
|
+
* Covers: EN · DE · FR · ES · IT · PT · NL
|
|
8
|
+
* Source of truth for keyword lists: sdk/shared/filler-words.ts
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
const CODE_KW = [
|
|
12
|
+
'function ', 'def ', 'class ', 'import ', 'const ', 'let ', 'var ',
|
|
13
|
+
'return ', ' => ', 'void ', 'public class', 'func ', '#include', 'package ',
|
|
14
|
+
'struct ', 'interface ', 'async def', 'lambda ', '#!/',
|
|
15
|
+
];
|
|
16
|
+
|
|
17
|
+
// Translation – EN · DE · FR · ES · IT · PT · NL
|
|
18
|
+
const TRANSL_KW = [
|
|
19
|
+
// EN
|
|
20
|
+
'translate', 'in english', 'in german', 'in french', 'in spanish', 'in italian', 'in portuguese',
|
|
21
|
+
// DE
|
|
22
|
+
'übersetze', 'übersetz', 'auf deutsch', 'auf englisch', 'ins deutsche', 'ins englische',
|
|
23
|
+
// FR
|
|
24
|
+
'traduis', 'traduire', 'en français', 'en anglais', 'en allemand', 'en espagnol',
|
|
25
|
+
// ES
|
|
26
|
+
'traduce', 'traducir', 'al español', 'al inglés', 'al alemán',
|
|
27
|
+
// IT
|
|
28
|
+
'traduci', 'in italiano', 'in inglese', 'in tedesco',
|
|
29
|
+
// PT
|
|
30
|
+
'traduz', 'traduzir', 'em português', 'em inglês', 'em alemão',
|
|
31
|
+
// NL
|
|
32
|
+
'vertaal',
|
|
33
|
+
];
|
|
34
|
+
|
|
35
|
+
// Summary – EN · DE · FR · ES · IT · PT
|
|
36
|
+
const SUMMARY_KW = [
|
|
37
|
+
// EN
|
|
38
|
+
'summarize', 'summarise', 'summary', 'tl;dr', 'tldr',
|
|
39
|
+
'key points', 'give me a brief', 'in a nutshell', 'in short', 'overview of',
|
|
40
|
+
// DE
|
|
41
|
+
'zusammenfass', 'stichpunkte', 'fasse zusammen', 'kurze zusammenfassung', 'überblick',
|
|
42
|
+
// FR
|
|
43
|
+
'résume', 'résumé', 'résumer', 'points clés', 'en bref', "vue d'ensemble",
|
|
44
|
+
// ES
|
|
45
|
+
'resumir', 'en resumen', 'puntos clave', 'en breve', 'resumen de',
|
|
46
|
+
// IT
|
|
47
|
+
'riassumi', 'riassunto', 'punti chiave', 'in breve', 'panoramica',
|
|
48
|
+
// PT
|
|
49
|
+
'resumir', 'em resumo', 'pontos principais', 'resumo de',
|
|
50
|
+
];
|
|
51
|
+
|
|
52
|
+
// Q&A prefixes – EN · DE · FR · ES · IT · PT
|
|
53
|
+
const QA_PREFIXES = [
|
|
54
|
+
// EN
|
|
55
|
+
'what ', 'who ', 'where ', 'when ', 'why ', 'how ', 'which ',
|
|
56
|
+
'is ', 'are ', 'was ', 'were ', 'does ', 'do ', 'did ',
|
|
57
|
+
'can ', 'could ', 'would ', 'should ', 'will ',
|
|
58
|
+
// DE
|
|
59
|
+
'wer ', 'wie ', 'wo ', 'wann ', 'warum ', 'welche', 'wieso ', 'was ist',
|
|
60
|
+
// FR
|
|
61
|
+
"qu'est-ce que", 'comment ', 'pourquoi ', 'quel ', 'quelle ', 'quels ',
|
|
62
|
+
'est-ce que', 'qui est', 'où est', 'quand ',
|
|
63
|
+
// ES
|
|
64
|
+
'qué ', 'cómo ', 'quién ', 'dónde ', 'cuándo ', 'por qué ',
|
|
65
|
+
// IT
|
|
66
|
+
'come ', 'perché ', "cos'è", "com'è", 'dove ', 'quando ', 'chi è',
|
|
67
|
+
// PT
|
|
68
|
+
'o que ', 'como ', 'quem ', 'onde ', 'quando ', 'por que ',
|
|
69
|
+
];
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Classify a prompt into one of 5 semantic namespaces.
|
|
73
|
+
* Returns one of: `cachly:sem:code` | `:translation` | `:summary` | `:qa` | `:creative`
|
|
74
|
+
*/
|
|
75
|
+
export function detectNamespace(prompt: string): string {
|
|
76
|
+
const s = prompt.trim().toLowerCase();
|
|
77
|
+
if (CODE_KW.some((kw) => s.includes(kw))) return 'cachly:sem:code';
|
|
78
|
+
if (TRANSL_KW.some((kw) => s.includes(kw))) return 'cachly:sem:translation';
|
|
79
|
+
if (SUMMARY_KW.some((kw) => s.includes(kw))) return 'cachly:sem:summary';
|
|
80
|
+
if (QA_PREFIXES.some((p) => s.startsWith(p))) return 'cachly:sem:qa';
|
|
81
|
+
if (s.trimEnd().endsWith('?')) return 'cachly:sem:qa';
|
|
82
|
+
return 'cachly:sem:creative';
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Filler words used by prompt normalisation in MCP context.
|
|
87
|
+
* Source of truth: sdk/shared/filler-words.ts
|
|
88
|
+
* Covers: EN · DE · FR · ES · IT · PT
|
|
89
|
+
*/
|
|
90
|
+
export const FILLER_WORDS: string[] = [
|
|
91
|
+
// EN
|
|
92
|
+
'please', 'hey', 'hi', 'hello',
|
|
93
|
+
'could you', 'can you', 'would you', 'will you',
|
|
94
|
+
'just', 'quickly', 'briefly', 'simply',
|
|
95
|
+
'tell me', 'show me', 'give me', 'help me', 'assist me',
|
|
96
|
+
'explain to me', 'describe to me',
|
|
97
|
+
'i need', 'i want', 'i would like', "i'd like", "i'm looking for",
|
|
98
|
+
// DE
|
|
99
|
+
'bitte', 'mal eben', 'schnell', 'kurz', 'einfach',
|
|
100
|
+
'kannst du', 'könntest du', 'könnten sie', 'würden sie', 'würdest du',
|
|
101
|
+
'hallo', 'hi', 'hey',
|
|
102
|
+
'sag mir', 'zeig mir', 'gib mir', 'hilf mir', 'erkläre mir', 'erklär mir',
|
|
103
|
+
'ich brauche', 'ich möchte', 'ich hätte gerne', 'ich suche',
|
|
104
|
+
// FR
|
|
105
|
+
"s'il vous plaît", 'svp', 'stp', 'bonjour', 'salut', 'allô',
|
|
106
|
+
'pouvez-vous', 'pourriez-vous', 'peux-tu', 'pourrais-tu',
|
|
107
|
+
'dis-moi', 'dites-moi', 'montre-moi', 'montrez-moi',
|
|
108
|
+
"j'ai besoin de", 'je voudrais', 'je cherche', 'je souhaite',
|
|
109
|
+
'expliquez-moi', 'explique-moi', 'aidez-moi', 'aide-moi',
|
|
110
|
+
// ES
|
|
111
|
+
'por favor', 'hola', 'oye',
|
|
112
|
+
'puedes', 'podrías', 'podría usted', 'me puedes', 'me podrías',
|
|
113
|
+
'dime', 'dígame', 'muéstrame', 'muéstreme', 'dame', 'deme',
|
|
114
|
+
'necesito', 'quisiera', 'me gustaría', 'quiero saber',
|
|
115
|
+
'ayúdame', 'ayúdeme', 'explícame', 'explíqueme',
|
|
116
|
+
// IT
|
|
117
|
+
'per favore', 'perfavore', 'ciao', 'salve', 'ehi',
|
|
118
|
+
'potresti', 'mi potresti', 'potrebbe', 'mi potrebbe',
|
|
119
|
+
'dimmi', 'mi dica', 'mostrami', 'dammi', 'mi dia',
|
|
120
|
+
'ho bisogno di', 'vorrei', 'mi piacerebbe',
|
|
121
|
+
'aiutami', 'mi aiuti', 'spiegami', 'mi spieghi',
|
|
122
|
+
// PT
|
|
123
|
+
'por favor', 'olá', 'oi', 'ei',
|
|
124
|
+
'pode', 'poderia', 'você poderia', 'você pode', 'podes',
|
|
125
|
+
'me diga', 'diga-me', 'me mostre', 'mostre-me', 'me dê', 'dê-me',
|
|
126
|
+
'preciso de', 'gostaria de', 'quero saber', 'estou procurando',
|
|
127
|
+
'me ajude', 'ajude-me', 'explique-me', 'me explique',
|
|
128
|
+
];
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2022",
|
|
4
|
+
"module": "Node16",
|
|
5
|
+
"moduleResolution": "Node16",
|
|
6
|
+
"outDir": "./dist",
|
|
7
|
+
"rootDir": "./src",
|
|
8
|
+
"strict": true,
|
|
9
|
+
"esModuleInterop": true,
|
|
10
|
+
"skipLibCheck": true,
|
|
11
|
+
"declaration": true,
|
|
12
|
+
"sourceMap": true
|
|
13
|
+
},
|
|
14
|
+
"include": ["src/**/*"],
|
|
15
|
+
"exclude": ["node_modules", "dist"]
|
|
16
|
+
}
|
|
17
|
+
|