@cachly-dev/mcp-server 0.5.70 → 0.6.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.
@@ -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,97 +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.5.37] – 2026-04-24
11
-
12
- ### Added
13
-
14
- - **RTL language support (Arabic, Hebrew)** — word-level tokenization with Unicode ranges U+0590–U+05FF (Hebrew) and U+0600–U+06FF (Arabic); Arabic light stemmer strips definite article `ال` and single-char prefix particles (`و`,`ب`,`ل`,`ف`,`ك`)
15
- - **Arabic and Hebrew stopwords** — ~60 high-frequency function words per language added to the STOPWORDS set
16
- - **Romanization matching** — katakana segments now additionally emit Hepburn romaji tokens at index time (e.g. `デプロイ` → `depuroi`), so users can query Japanese docs using romaji
17
- - **Full katakana→romaji converter** — handles digraphs (シャ→sha, チェ→che, ファ→fa), voiced consonants, geminate consonants (ッ), long vowel marks (ー), and loanword combinations
18
- - **Cross-language retrieval** — 130+ tech term synonyms spanning EN↔JA↔ZH↔KO↔AR↔HE; searching `deploy` now finds docs containing `デプロイ`, `部署`, `배포` and vice versa; applies bidirectionally at tokenize time (zero runtime overhead)
19
- - **73 unit tests** all passing — new test suites for `katakanaToRomaji`, `arabicLightStem`, `expandCrossLingual`, RTL tokenization, and cross-lingual expansion
20
-
21
- ---
22
-
23
- ## [0.5.36] – 2026-04-22
24
-
25
- ### Added
26
-
27
- - **Roadmap tools** — `roadmap_add`, `roadmap_update`, `roadmap_list`, `roadmap_next` for persistent project planning inside the Brain
28
- - `session_start` now shows open roadmap items automatically
29
-
30
- ---
31
-
32
- ## [0.5.35] – 2026-04-20
33
-
34
- ### Added
35
-
36
- - **CJK language support** — Chinese (Simplified + Traditional), Japanese, Korean
37
- - Character bigram extraction for CJK Unicode ranges
38
- - ~140 CJK stopwords (Chinese particles, Japanese hiragana particles, Korean postpositions)
39
-
40
- ---
41
-
42
-
43
-
44
- ### Added
45
-
46
- - **`setup` command** — interactive zero-arg CLI wizard (`npx @cachly-dev/mcp-server setup`):
47
- - Reads `CACHLY_JWT` from env or prompts interactively via readline
48
- - Fetches instances from API; presents list when multiple exist
49
- - Auto-detects installed editors (Cursor, Windsurf, VS Code, Continue.dev) by checking for their config directories
50
- - Writes the correct MCP config file for each detected editor in one step
51
- - Always writes/updates `CLAUDE.md` (idempotent via `<!-- cachly-brain-start/end -->` markers)
52
- - **`init` command** now idempotent — re-running `npx @cachly-dev/mcp-server init` updates the brain block in `CLAUDE.md` instead of appending a duplicate
53
- - Shared helpers: `buildMcpConfig()`, `buildClaudeMdBlock()`, `writeClaudeMd()` — used by both `setup` and `init`
54
-
55
- ### Fixed
56
-
57
- - `init` no longer duplicates the brain block in `CLAUDE.md` when run multiple times
58
- - Correct package name `@cachly-dev/mcp-server` used consistently (was `@cachly-dev/mcp` in generated configs)
59
-
60
- ---
61
-
62
- ## [0.1.1] – 2026-04-07
63
-
64
- ### Fixed
65
-
66
- - Broken `index_project` tool schema – properties were accidentally placed outside the `TOOLS` array
67
- - Unused `openai` variable removed from `cache_warmup` handler
68
- - `readdir` type mismatch (`Dirent<string>` vs. `NonSharedBuffer`) fixed
69
- - Version bumped to `0.3.0` in server metadata
70
-
71
- ---
72
-
73
- ## [0.1.0] – 2026-04-07
74
-
75
- Initial release.
76
-
77
- ### Added
78
-
79
- - MCP tool: `cache_set` – store a value with optional TTL
80
- - MCP tool: `cache_get` – retrieve a cached value
81
- - MCP tool: `cache_delete` – remove a key
82
- - MCP tool: `semantic_search` – vector-similarity lookup for LLM response caching
83
- - MCP tool: `cache_clear` – flush namespace or entire cache
84
- - Compatible with Claude Desktop, Cursor, Windsurf, and any MCP-capable host
85
- - API-key-based authentication
86
- - EU data residency (German servers, DSGVO compliant)
87
-
88
- ### Known limitations
89
-
90
- - ~~Streaming tools not yet supported~~ (tracked for a future release)
91
-
92
- ---
93
-
94
- ## [Unreleased]
95
-
96
- See [../CHANGELOG.md](../CHANGELOG.md) for upcoming features.
97
-
@@ -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,EAAE,CAAC,IAAI,CAAC;YACN,CAAC,YAAY,EAAS,oCAAoC,CAAC;YAC3D,CAAC,gBAAgB,EAAK,0CAA0C,CAAC;YACjE,CAAC,UAAU,EAAW,0DAA0D,CAAC;YACjF,CAAC,kBAAkB,EAAG,kCAAkC,CAAC;YACzD,CAAC,cAAc,EAAO,wCAAwC,CAAC;YAC/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AC;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"}
@@ -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
-
package/test-features.cjs DELETED
@@ -1,23 +0,0 @@
1
- const fs = require('fs');
2
-
3
- const src = fs.readFileSync('src/index.ts', 'utf8');
4
- const initSrc = fs.readFileSync('../init/index.js', 'utf8');
5
- const pkg = JSON.parse(fs.readFileSync('package.json', 'utf8'));
6
-
7
- let pass = 0, fail = 0;
8
- function check(name, cond) {
9
- if (cond) { console.log('PASS:', name); pass++; }
10
- else { console.log('FAIL:', name); fail++; }
11
- }
12
-
13
- check('Test 1 - Ambient git learning in session_end', src.includes('git log --since') || src.includes('Ambient git'));
14
- check('Test 2a - author param in learn_from_attempts schema', src.includes('"author"') && src.includes('learn_from_attempts'));
15
- check('Test 2b - Team Telepathy in session_start', src.includes('Team Telepathy') || src.includes('team telepathy'));
16
- check('Test 3 - memory_crystalize tool', src.includes('memory_crystalize'));
17
- check('Test 4 - init team detection (~/.cachly-teams.json)', initSrc.includes('cachly-teams.json'));
18
- check('Test 5 - brain_doctor workspace_path param', src.includes('workspace_path') && src.includes('brain_doctor'));
19
- check('Bugfix - Pre-Warning uses splice(2,0)', src.includes('splice(2, 0'));
20
- check('Bugfix - No broken unshift in pre-warning', !src.includes('lines.unshift('));
21
- check('MCP version is 0.5.26', pkg.version === '0.5.26');
22
-
23
- console.log(`\n${pass}/${pass+fail} tests passed`);