@cachly-dev/mcp-server 0.5.37 → 0.5.39

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.
@@ -4,16 +4,13 @@
4
4
  * Run: npx vitest run src/search.test.ts
5
5
  */
6
6
  import { describe, it, expect } from 'vitest';
7
- import { tokenize, splitMultiQuery, levenshtein, recencyBoost, extractTimestamp, STOPWORDS,
8
- katakanaToRomaji, arabicLightStem, expandCrossLingual, CROSS_LINGUAL_MAP } from './index.js';
7
+ import { tokenize, splitMultiQuery, levenshtein, recencyBoost, extractTimestamp, STOPWORDS } from './index.js';
9
8
 
10
9
  // ── Tokenizer ─────────────────────────────────────────────────────────────────
11
10
 
12
11
  describe('tokenize', () => {
13
12
  it('lowercases and splits on whitespace', () => {
14
- const result = tokenize('Deploy API');
15
- expect(result).toContain('deploy');
16
- expect(result).toContain('api');
13
+ expect(tokenize('Deploy API')).toEqual(['deploy', 'api']);
17
14
  });
18
15
 
19
16
  it('filters English stopwords', () => {
@@ -72,12 +69,7 @@ describe('tokenize', () => {
72
69
  });
73
70
 
74
71
  it('removes single-char tokens', () => {
75
- const result = tokenize('a b c deploy');
76
- expect(result).toContain('deploy');
77
- // single chars a, b, c must not appear
78
- expect(result).not.toContain('a');
79
- expect(result).not.toContain('b');
80
- expect(result).not.toContain('c');
72
+ expect(tokenize('a b c deploy')).toEqual(['deploy']);
81
73
  });
82
74
 
83
75
  it('preserves colons and dots in tokens (topic slugs)', () => {
@@ -288,209 +280,3 @@ describe('extractTimestamp', () => {
288
280
  expect(extractTimestamp('{"ts":"not-a-date"}')).toBeUndefined();
289
281
  });
290
282
  });
291
-
292
- // ── Katakana → Romaji ──────────────────────────────────────────────────────────
293
-
294
- describe('katakanaToRomaji', () => {
295
- it('converts basic katakana vowels', () => {
296
- expect(katakanaToRomaji('アイウエオ')).toBe('aiueo');
297
- });
298
-
299
- it('converts コンテナ (container)', () => {
300
- expect(katakanaToRomaji('コンテナ')).toBe('kontena');
301
- });
302
-
303
- it('converts デプロイ (deploy)', () => {
304
- expect(katakanaToRomaji('デプロイ')).toBe('depuroi');
305
- });
306
-
307
- it('converts サーバー (server) — long vowel stripped', () => {
308
- const r = katakanaToRomaji('サーバー');
309
- expect(r).toContain('sa');
310
- expect(r).toContain('ba');
311
- });
312
-
313
- it('converts digraph チェック (check)', () => {
314
- const r = katakanaToRomaji('チェック');
315
- expect(r).toContain('che');
316
- });
317
-
318
- it('converts ファイル (file)', () => {
319
- const r = katakanaToRomaji('ファイル');
320
- expect(r).toContain('fa');
321
- });
322
-
323
- it('handles empty string', () => {
324
- expect(katakanaToRomaji('')).toBe('');
325
- });
326
- });
327
-
328
- // ── Arabic Light Stemmer ───────────────────────────────────────────────────────
329
-
330
- describe('arabicLightStem', () => {
331
- it('strips definite article ال (al-)', () => {
332
- // الخطأ (al-khata = the error) → خطأ (khata)
333
- expect(arabicLightStem('الخطأ')).toBe('خطأ');
334
- });
335
-
336
- it('strips و (wa-) prefix from long words', () => {
337
- // وخطأ → خطأ (and error → error)
338
- expect(arabicLightStem('وخطأ')).toBe('خطأ');
339
- });
340
-
341
- it('strips ب (bi-) prefix', () => {
342
- expect(arabicLightStem('بسرعة')).toBe('سرعة');
343
- });
344
-
345
- it('does not strip from short words (≤3 chars)', () => {
346
- // بلد (3 chars) should not be stripped
347
- expect(arabicLightStem('بلد')).toBe('بلد');
348
- });
349
-
350
- it('returns unchanged for Latin input', () => {
351
- expect(arabicLightStem('deploy')).toBe('deploy');
352
- });
353
- });
354
-
355
- // ── Cross-lingual Expansion ────────────────────────────────────────────────────
356
-
357
- describe('expandCrossLingual', () => {
358
- it('returns Japanese katakana for "deploy"', () => {
359
- const syns = expandCrossLingual('deploy');
360
- expect(syns).toContain('デプロイ');
361
- });
362
-
363
- it('returns Chinese for "deploy"', () => {
364
- expect(expandCrossLingual('deploy')).toContain('部署');
365
- });
366
-
367
- it('returns Korean for "deploy"', () => {
368
- expect(expandCrossLingual('deploy')).toContain('배포');
369
- });
370
-
371
- it('returns English for Japanese デプロイ', () => {
372
- expect(expandCrossLingual('デプロイ')).toContain('deploy');
373
- });
374
-
375
- it('returns English for Chinese 部署', () => {
376
- expect(expandCrossLingual('部署')).toContain('deploy');
377
- });
378
-
379
- it('returns English for Korean 배포', () => {
380
- expect(expandCrossLingual('배포')).toContain('deploy');
381
- });
382
-
383
- it('returns English for Arabic خطأ (error)', () => {
384
- expect(expandCrossLingual('خطأ')).toContain('error');
385
- });
386
-
387
- it('returns English for Hebrew שגיאה (error)', () => {
388
- expect(expandCrossLingual('שגיאה')).toContain('error');
389
- });
390
-
391
- it('returns empty array for unknown tokens', () => {
392
- expect(expandCrossLingual('foobar')).toEqual([]);
393
- });
394
-
395
- it('covers all major languages for "server"', () => {
396
- const syns = expandCrossLingual('server');
397
- expect(syns).toContain('サーバー');
398
- expect(syns).toContain('服务器');
399
- expect(syns).toContain('서버');
400
- });
401
-
402
- it('has at least 50 tech terms in the map', () => {
403
- expect(CROSS_LINGUAL_MAP.size).toBeGreaterThanOrEqual(50);
404
- });
405
- });
406
-
407
- // ── RTL Tokenization ───────────────────────────────────────────────────────────
408
-
409
- describe('tokenize — RTL (Arabic/Hebrew)', () => {
410
- it('tokenizes Arabic text into words', () => {
411
- // "خطأ في النظام" = error in the system
412
- const tokens = tokenize('خطأ في النظام');
413
- expect(tokens.length).toBeGreaterThan(0);
414
- // خطأ = error, not a stopword
415
- const hasError = tokens.some(t => t === 'خطأ' || t === 'error');
416
- expect(hasError).toBe(true);
417
- });
418
-
419
- it('strips Arabic definite article via light stemmer', () => {
420
- // النظام → نظام (the system → system)
421
- const tokens = tokenize('النظام');
422
- expect(tokens).toContain('نظام');
423
- });
424
-
425
- it('filters Arabic stopwords', () => {
426
- const tokens = tokenize('في على من');
427
- // All three are stopwords
428
- expect(tokens.filter(t => RTL_RE_TEST(t)).length).toBe(0);
429
- });
430
-
431
- it('tokenizes Hebrew text', () => {
432
- // שגיאה = error
433
- const tokens = tokenize('שגיאה בשרת');
434
- expect(tokens.length).toBeGreaterThan(0);
435
- const hasErr = tokens.some(t => t === 'שגיאה' || t === 'error');
436
- expect(hasErr).toBe(true);
437
- });
438
-
439
- it('handles mixed Arabic + English text', () => {
440
- const tokens = tokenize('deploy خطأ error');
441
- expect(tokens).toContain('deploy');
442
- expect(tokens.some(t => t === 'خطأ' || t === 'error')).toBe(true);
443
- });
444
- });
445
-
446
- // Helper: test if a string contains RTL characters
447
- function RTL_RE_TEST(s: string) {
448
- return /[\u0590-\u05ff\u0600-\u06ff]/.test(s);
449
- }
450
-
451
- // ── Cross-lingual Search Integration ──────────────────────────────────────────
452
-
453
- describe('tokenize — cross-lingual expansion', () => {
454
- it('English "deploy" expands to Japanese bigrams', () => {
455
- const tokens = tokenize('deploy');
456
- // デプロイ bigrams: デプ, プロ, ロイ
457
- expect(tokens.some(t => t === 'デプ' || t === 'プロ' || t === 'ロイ')).toBe(true);
458
- });
459
-
460
- it('Japanese デプロイ expands to include "deploy"', () => {
461
- const tokens = tokenize('デプロイ');
462
- expect(tokens).toContain('deploy');
463
- });
464
-
465
- it('Chinese 部署 expands to "deploy"', () => {
466
- const tokens = tokenize('部署');
467
- expect(tokens).toContain('deploy');
468
- });
469
-
470
- it('Korean 배포 expands to "deploy"', () => {
471
- const tokens = tokenize('배포');
472
- expect(tokens).toContain('deploy');
473
- });
474
-
475
- it('Arabic خطأ expands to "error"', () => {
476
- const tokens = tokenize('خطأ');
477
- expect(tokens).toContain('error');
478
- });
479
-
480
- it('Hebrew שגיאה expands to "error"', () => {
481
- const tokens = tokenize('שגיאה');
482
- expect(tokens).toContain('error');
483
- });
484
-
485
- it('English "container" expands to all CJK variants', () => {
486
- const tokens = tokenize('container');
487
- // コンテナ bigrams should be present
488
- expect(tokens.some(t => t === 'コン' || t === 'ンテ' || t === 'テナ')).toBe(true);
489
- });
490
-
491
- it('katakana コンテナ generates romaji "kontena"', () => {
492
- const tokens = tokenize('コンテナ');
493
- expect(tokens).toContain('kontena');
494
- });
495
- });
496
-
package/CHANGELOG.md DELETED
@@ -1,65 +0,0 @@
1
- # Changelog – cachly SDK (mcp)
2
-
3
- **Language:** MCP (Model Context Protocol)
4
- **Package:** `@cachly-dev/mcp-server` on **npm**
5
-
6
- > Full cross-SDK release notes: [../CHANGELOG.md](../CHANGELOG.md)
7
-
8
- ---
9
-
10
- ## [0.2.0] – 2026-04-17
11
-
12
- ### Added
13
-
14
- - **`setup` command** — interactive zero-arg CLI wizard (`npx @cachly-dev/mcp-server setup`):
15
- - Reads `CACHLY_JWT` from env or prompts interactively via readline
16
- - Fetches instances from API; presents list when multiple exist
17
- - Auto-detects installed editors (Cursor, Windsurf, VS Code, Continue.dev) by checking for their config directories
18
- - Writes the correct MCP config file for each detected editor in one step
19
- - Always writes/updates `CLAUDE.md` (idempotent via `<!-- cachly-brain-start/end -->` markers)
20
- - **`init` command** now idempotent — re-running `npx @cachly-dev/mcp-server init` updates the brain block in `CLAUDE.md` instead of appending a duplicate
21
- - Shared helpers: `buildMcpConfig()`, `buildClaudeMdBlock()`, `writeClaudeMd()` — used by both `setup` and `init`
22
-
23
- ### Fixed
24
-
25
- - `init` no longer duplicates the brain block in `CLAUDE.md` when run multiple times
26
- - Correct package name `@cachly-dev/mcp-server` used consistently (was `@cachly-dev/mcp` in generated configs)
27
-
28
- ---
29
-
30
- ## [0.1.1] – 2026-04-07
31
-
32
- ### Fixed
33
-
34
- - Broken `index_project` tool schema – properties were accidentally placed outside the `TOOLS` array
35
- - Unused `openai` variable removed from `cache_warmup` handler
36
- - `readdir` type mismatch (`Dirent<string>` vs. `NonSharedBuffer`) fixed
37
- - Version bumped to `0.3.0` in server metadata
38
-
39
- ---
40
-
41
- ## [0.1.0] – 2026-04-07
42
-
43
- Initial release.
44
-
45
- ### Added
46
-
47
- - MCP tool: `cache_set` – store a value with optional TTL
48
- - MCP tool: `cache_get` – retrieve a cached value
49
- - MCP tool: `cache_delete` – remove a key
50
- - MCP tool: `semantic_search` – vector-similarity lookup for LLM response caching
51
- - MCP tool: `cache_clear` – flush namespace or entire cache
52
- - Compatible with Claude Desktop, Cursor, Windsurf, and any MCP-capable host
53
- - API-key-based authentication
54
- - EU data residency (German servers, DSGVO compliant)
55
-
56
- ### Known limitations
57
-
58
- - ~~Streaming tools not yet supported~~ (tracked for a future release)
59
-
60
- ---
61
-
62
- ## [Unreleased]
63
-
64
- See [../CHANGELOG.md](../CHANGELOG.md) for upcoming features.
65
-
@@ -1 +0,0 @@
1
- export {};
@@ -1,114 +0,0 @@
1
- import { describe, it, expect } from 'vitest';
2
- import { detectNamespace } from '../namespace.js';
3
- // ── Namespace Auto-Detection ───────────────────────────────────────────────
4
- describe('detectNamespace', () => {
5
- // ── Code ────────────────────────────────────────────────────────────────────
6
- describe('code detection', () => {
7
- it.each([
8
- ['python def', 'def process(data): return data * 2'],
9
- ['js const arrow', 'const handler = () => response.send(200)'],
10
- ['ts class', 'class UserService { constructor(private repo: Repo) {} }'],
11
- ['import statement', 'import { useState } from "react"'],
12
- ['shebang line', '#!/usr/bin/env python3\nprint("hello")'],
13
- ['go func', 'func main() { fmt.Println("hello") }'],
14
- ['cpp include', '#include <iostream>\nint main() { return 0; }'],
15
- ['interface block', 'interface ICache { get(key: string): void; }'],
16
- ['struct block', 'struct Config { host string }'],
17
- ['async def', 'async def fetch_data(url: str) -> dict:'],
18
- ['lambda', 'fn = lambda x: x * 2'],
19
- ['package decl', 'package com.example.service;'],
20
- ])('detects code: %s', (_, prompt) => {
21
- expect(detectNamespace(prompt)).toBe('cachly:sem:code');
22
- });
23
- });
24
- // ── Translation ─────────────────────────────────────────────────────────────
25
- describe('translation detection', () => {
26
- it.each([
27
- ['translate', 'translate this paragraph to Spanish'],
28
- ['übersetze', 'übersetze diesen Text bitte'],
29
- ['auf deutsch', 'Schreib das auf deutsch'],
30
- ['in english', 'Please write this in english'],
31
- ['ins deutsche', 'Bitte übersetze ins Deutsche'],
32
- ['traduce', 'traduce este texto al alemán'],
33
- ['traduis', 'traduis ce texte en anglais'],
34
- ['vertaal', 'vertaal dit naar het Nederlands'],
35
- ])('detects translation: %s', (_, prompt) => {
36
- expect(detectNamespace(prompt)).toBe('cachly:sem:translation');
37
- });
38
- });
39
- // ── Summary ──────────────────────────────────────────────────────────────────
40
- describe('summary detection', () => {
41
- it.each([
42
- ['summarize', 'summarize this article for me'],
43
- ['summarise', 'summarise the key points'],
44
- ['tl;dr', 'tl;dr of the following blog post:'],
45
- ['tldr', 'tldr of this document'],
46
- ['key points', 'what are the key points?'],
47
- ['zusammenfass', 'fasse zusammen worum es geht'],
48
- ['give me a brief', 'give me a brief overview'],
49
- ['in a nutshell', 'explain machine learning in a nutshell'],
50
- ['stichpunkte', 'Gib mir die wichtigsten Stichpunkte'],
51
- ])('detects summary: %s', (_, prompt) => {
52
- expect(detectNamespace(prompt)).toBe('cachly:sem:summary');
53
- });
54
- });
55
- // ── Q&A ──────────────────────────────────────────────────────────────────────
56
- describe('qa detection', () => {
57
- it.each([
58
- ['what is', 'what is the capital of France?'],
59
- ['how does', 'how does photosynthesis work?'],
60
- ['why is', 'why is the sky blue?'],
61
- ['who invented', 'who invented the internet?'],
62
- ['where is', 'where is Mount Everest located?'],
63
- ['when was', 'when was the Eiffel Tower built?'],
64
- ['can you', 'can you explain recursion?'],
65
- ['is redis', 'is Redis single-threaded?'],
66
- ['does postgres', 'does postgres support JSON natively?'],
67
- ['wer ist', 'wer ist der aktuelle Bundeskanzler?'],
68
- ['wie funktioniert', 'wie funktioniert ein JWT Token?'],
69
- ['trailing ?', 'Redis vs Memcached?'],
70
- ])('detects q&a: %s', (_, prompt) => {
71
- expect(detectNamespace(prompt)).toBe('cachly:sem:qa');
72
- });
73
- });
74
- // ── Creative ─────────────────────────────────────────────────────────────────
75
- describe('creative fallback', () => {
76
- it.each([
77
- ['poem request', 'Write a short poem about autumn leaves'],
78
- ['story request', 'Tell me a fantasy story about dragons'],
79
- ['product copy', 'Generate a product description for running shoes'],
80
- ['greeting', 'Good morning, how are you today'],
81
- ['general task', 'Help me brainstorm names for my startup'],
82
- ])('falls back to creative: %s', (_, prompt) => {
83
- expect(detectNamespace(prompt)).toBe('cachly:sem:creative');
84
- });
85
- });
86
- // ── Edge cases ────────────────────────────────────────────────────────────────
87
- describe('edge cases', () => {
88
- it('is case-insensitive', () => {
89
- expect(detectNamespace('CONST x = 1')).toBe('cachly:sem:code');
90
- expect(detectNamespace('TRANSLATE THIS')).toBe('cachly:sem:translation');
91
- expect(detectNamespace('SUMMARIZE PLEASE')).toBe('cachly:sem:summary');
92
- expect(detectNamespace('WHAT IS GRAVITY?')).toBe('cachly:sem:qa');
93
- });
94
- it('trims surrounding whitespace', () => {
95
- expect(detectNamespace(' what is Redis? ')).toBe('cachly:sem:qa');
96
- expect(detectNamespace(' const x = 1 ')).toBe('cachly:sem:code');
97
- });
98
- it('code keyword takes priority over translation', () => {
99
- // Both "translate" and "def" present – code wins (checked first)
100
- expect(detectNamespace('translate this function: def foo(): pass')).toBe('cachly:sem:code');
101
- });
102
- it('code keyword takes priority over summary', () => {
103
- expect(detectNamespace('summarize this class MyService { }'))
104
- .toBe('cachly:sem:code');
105
- });
106
- it('handles empty string as creative', () => {
107
- expect(detectNamespace('')).toBe('cachly:sem:creative');
108
- });
109
- it('a single ? at end is qa', () => {
110
- expect(detectNamespace('Interesting concept?')).toBe('cachly:sem:qa');
111
- });
112
- });
113
- });
114
- //# sourceMappingURL=namespace.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"namespace.test.js","sourceRoot":"","sources":["../../src/__tests__/namespace.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAElD,8EAA8E;AAE9E,QAAQ,CAAC,iBAAiB,EAAE,GAAG,EAAE;IAC/B,+EAA+E;IAC/E,QAAQ,CAAC,gBAAgB,EAAE,GAAG,EAAE;QAC9B,EAA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8BAA8B,EAAE,GAAG,EAAE;YACtC,MAAM,CAAC,eAAe,CAAC,sBAAsB,CAAC,CAAC,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;YACtE,MAAM,CAAC,eAAe,CAAC,iBAAiB,CAAC,CAAC,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC;QACrE,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,8CAA8C,EAAE,GAAG,EAAE;YACtD,iEAAiE;YACjE,MAAM,CAAC,eAAe,CAAC,0CAA0C,CAAC,CAAC,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC;QAC9F,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,0CAA0C,EAAE,GAAG,EAAE;YAClD,MAAM,CAAC,eAAe,CAAC,oCAAoC,CAAC,CAAC;iBAC1D,IAAI,CAAC,iBAAiB,CAAC,CAAC;QAC7B,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,kCAAkC,EAAE,GAAG,EAAE;YAC1C,MAAM,CAAC,eAAe,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAC;QAC1D,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,yBAAyB,EAAE,GAAG,EAAE;YACjC,MAAM,CAAC,eAAe,CAAC,sBAAsB,CAAC,CAAC,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;QACxE,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
package/run-mcp.sh DELETED
@@ -1,57 +0,0 @@
1
- #!/usr/bin/env python3
2
- # MCP server wrapper – tees all stdin/stdout/stderr to /tmp/cachly-mcp.log
3
- import subprocess, sys, os, threading, datetime
4
-
5
- LOG = "/tmp/cachly-mcp.log"
6
- SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
7
-
8
- def ts():
9
- return datetime.datetime.now().strftime('%H:%M:%S.%f')[:-3]
10
-
11
- log = open(LOG, 'a')
12
-
13
- def w(tag, data):
14
- try:
15
- text = data.decode(errors='replace').rstrip()
16
- log.write(f'[{ts()}] {tag}: {text}\n')
17
- log.flush()
18
- except Exception:
19
- pass
20
-
21
- proc = subprocess.Popen(
22
- ['node', os.path.join(SCRIPT_DIR, 'dist/index.js')],
23
- stdin=subprocess.PIPE,
24
- stdout=subprocess.PIPE,
25
- stderr=subprocess.PIPE,
26
- env=os.environ,
27
- )
28
-
29
- log.write(f'[{ts()}] START pid={proc.pid}\n'); log.flush()
30
-
31
- def pipe_in():
32
- while True:
33
- chunk = sys.stdin.buffer.read(4096)
34
- if not chunk:
35
- break
36
- w('IN ', chunk)
37
- proc.stdin.write(chunk)
38
- proc.stdin.flush()
39
- proc.stdin.close()
40
-
41
- def pipe_out(src, dst, tag):
42
- while True:
43
- chunk = src.read(4096)
44
- if not chunk:
45
- break
46
- w(tag, chunk)
47
- dst.buffer.write(chunk)
48
- dst.buffer.flush()
49
-
50
- t1 = threading.Thread(target=pipe_in, daemon=True)
51
- t2 = threading.Thread(target=pipe_out, args=(proc.stdout, sys.stdout, 'OUT'), daemon=True)
52
- t3 = threading.Thread(target=pipe_out, args=(proc.stderr, sys.stderr, 'ERR'), daemon=True)
53
- for t in (t1, t2, t3): t.start()
54
-
55
- rc = proc.wait()
56
- log.write(f'[{ts()}] EXIT code={rc}\n'); log.flush()
57
- sys.exit(rc)
@@ -1,36 +0,0 @@
1
- #!/usr/bin/env node
2
- // Shown once after: npm install @cachly-dev/mcp-server
3
-
4
- const c = {
5
- reset: "\x1b[0m",
6
- bold: "\x1b[1m",
7
- violet: "\x1b[35m",
8
- green: "\x1b[32m",
9
- cyan: "\x1b[36m",
10
- yellow: "\x1b[33m",
11
- dim: "\x1b[2m",
12
- };
13
-
14
- const line = `${c.dim}─────────────────────────────────────────────────────${c.reset}`;
15
-
16
- console.log(`
17
- ${line}
18
- ${c.bold}${c.violet}🧠 Cachly Brain MCP Server${c.reset} ${c.dim}v${process.env.npm_package_version ?? ""}${c.reset}
19
-
20
- ${c.bold}Give your AI assistant persistent memory in 30 seconds:${c.reset}
21
-
22
- ${c.cyan}1.${c.reset} Get a free Brain instance at ${c.bold}cachly.dev/setup-ai${c.reset}
23
- ${c.cyan}2.${c.reset} Add to Claude Code / Cursor / Copilot / Windsurf:
24
- ${c.dim}npx @cachly-dev/mcp-server@latest init${c.reset}
25
-
26
- ${c.green}✅ Free tier · GDPR · German servers · No credit card${c.reset}
27
-
28
- ${c.dim}──────────────────────────────────────────────────────${c.reset}
29
- ${c.yellow}📦 Related packages:${c.reset}
30
- ${c.cyan}@cachly-dev/openclaw${c.reset} Cut LLM costs 60–90% in JS/TS apps
31
- ${c.dim}npm install @cachly-dev/openclaw${c.reset}
32
- ${c.cyan}cachly${c.reset} CLI to manage your Brain instances
33
- ${c.dim}npm install -g cachly${c.reset}
34
-
35
- ${line}`);
36
-
@@ -1,126 +0,0 @@
1
- import { describe, it, expect } from 'vitest';
2
- import { detectNamespace } from '../namespace.js';
3
-
4
- // ── Namespace Auto-Detection ───────────────────────────────────────────────
5
-
6
- describe('detectNamespace', () => {
7
- // ── Code ────────────────────────────────────────────────────────────────────
8
- describe('code detection', () => {
9
- it.each([
10
- ['python def', 'def process(data): return data * 2'],
11
- ['js const arrow', 'const handler = () => response.send(200)'],
12
- ['ts class', 'class UserService { constructor(private repo: Repo) {} }'],
13
- ['import statement', 'import { useState } from "react"'],
14
- ['shebang line', '#!/usr/bin/env python3\nprint("hello")'],
15
- ['go func', 'func main() { fmt.Println("hello") }'],
16
- ['cpp include', '#include <iostream>\nint main() { return 0; }'],
17
- ['interface block', 'interface ICache { get(key: string): void; }'],
18
- ['struct block', 'struct Config { host string }'],
19
- ['async def', 'async def fetch_data(url: str) -> dict:'],
20
- ['lambda', 'fn = lambda x: x * 2'],
21
- ['package decl', 'package com.example.service;'],
22
- ])('detects code: %s', (_, prompt) => {
23
- expect(detectNamespace(prompt)).toBe('cachly:sem:code');
24
- });
25
- });
26
-
27
- // ── Translation ─────────────────────────────────────────────────────────────
28
- describe('translation detection', () => {
29
- it.each([
30
- ['translate', 'translate this paragraph to Spanish'],
31
- ['übersetze', 'übersetze diesen Text bitte'],
32
- ['auf deutsch', 'Schreib das auf deutsch'],
33
- ['in english', 'Please write this in english'],
34
- ['ins deutsche', 'Bitte übersetze ins Deutsche'],
35
- ['traduce', 'traduce este texto al alemán'],
36
- ['traduis', 'traduis ce texte en anglais'],
37
- ['vertaal', 'vertaal dit naar het Nederlands'],
38
- ])('detects translation: %s', (_, prompt) => {
39
- expect(detectNamespace(prompt)).toBe('cachly:sem:translation');
40
- });
41
- });
42
-
43
- // ── Summary ──────────────────────────────────────────────────────────────────
44
- describe('summary detection', () => {
45
- it.each([
46
- ['summarize', 'summarize this article for me'],
47
- ['summarise', 'summarise the key points'],
48
- ['tl;dr', 'tl;dr of the following blog post:'],
49
- ['tldr', 'tldr of this document'],
50
- ['key points', 'what are the key points?'],
51
- ['zusammenfass', 'fasse zusammen worum es geht'],
52
- ['give me a brief', 'give me a brief overview'],
53
- ['in a nutshell', 'explain machine learning in a nutshell'],
54
- ['stichpunkte', 'Gib mir die wichtigsten Stichpunkte'],
55
- ])('detects summary: %s', (_, prompt) => {
56
- expect(detectNamespace(prompt)).toBe('cachly:sem:summary');
57
- });
58
- });
59
-
60
- // ── Q&A ──────────────────────────────────────────────────────────────────────
61
- describe('qa detection', () => {
62
- it.each([
63
- ['what is', 'what is the capital of France?'],
64
- ['how does', 'how does photosynthesis work?'],
65
- ['why is', 'why is the sky blue?'],
66
- ['who invented', 'who invented the internet?'],
67
- ['where is', 'where is Mount Everest located?'],
68
- ['when was', 'when was the Eiffel Tower built?'],
69
- ['can you', 'can you explain recursion?'],
70
- ['is redis', 'is Redis single-threaded?'],
71
- ['does postgres', 'does postgres support JSON natively?'],
72
- ['wer ist', 'wer ist der aktuelle Bundeskanzler?'],
73
- ['wie funktioniert', 'wie funktioniert ein JWT Token?'],
74
- ['trailing ?', 'Redis vs Memcached?'],
75
- ])('detects q&a: %s', (_, prompt) => {
76
- expect(detectNamespace(prompt)).toBe('cachly:sem:qa');
77
- });
78
- });
79
-
80
- // ── Creative ─────────────────────────────────────────────────────────────────
81
- describe('creative fallback', () => {
82
- it.each([
83
- ['poem request', 'Write a short poem about autumn leaves'],
84
- ['story request', 'Tell me a fantasy story about dragons'],
85
- ['product copy', 'Generate a product description for running shoes'],
86
- ['greeting', 'Good morning, how are you today'],
87
- ['general task', 'Help me brainstorm names for my startup'],
88
- ])('falls back to creative: %s', (_, prompt) => {
89
- expect(detectNamespace(prompt)).toBe('cachly:sem:creative');
90
- });
91
- });
92
-
93
- // ── Edge cases ────────────────────────────────────────────────────────────────
94
- describe('edge cases', () => {
95
- it('is case-insensitive', () => {
96
- expect(detectNamespace('CONST x = 1')).toBe('cachly:sem:code');
97
- expect(detectNamespace('TRANSLATE THIS')).toBe('cachly:sem:translation');
98
- expect(detectNamespace('SUMMARIZE PLEASE')).toBe('cachly:sem:summary');
99
- expect(detectNamespace('WHAT IS GRAVITY?')).toBe('cachly:sem:qa');
100
- });
101
-
102
- it('trims surrounding whitespace', () => {
103
- expect(detectNamespace(' what is Redis? ')).toBe('cachly:sem:qa');
104
- expect(detectNamespace(' const x = 1 ')).toBe('cachly:sem:code');
105
- });
106
-
107
- it('code keyword takes priority over translation', () => {
108
- // Both "translate" and "def" present – code wins (checked first)
109
- expect(detectNamespace('translate this function: def foo(): pass')).toBe('cachly:sem:code');
110
- });
111
-
112
- it('code keyword takes priority over summary', () => {
113
- expect(detectNamespace('summarize this class MyService { }'))
114
- .toBe('cachly:sem:code');
115
- });
116
-
117
- it('handles empty string as creative', () => {
118
- expect(detectNamespace('')).toBe('cachly:sem:creative');
119
- });
120
-
121
- it('a single ? at end is qa', () => {
122
- expect(detectNamespace('Interesting concept?')).toBe('cachly:sem:qa');
123
- });
124
- });
125
- });
126
-