@felkot/think-mcp 1.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.
Files changed (49) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +165 -0
  3. package/dist/constants/index.d.ts +5 -0
  4. package/dist/constants/index.js +5 -0
  5. package/dist/constants/patterns.d.ts +8 -0
  6. package/dist/constants/patterns.js +34 -0
  7. package/dist/constants/prompts.d.ts +1 -0
  8. package/dist/constants/prompts.js +44 -0
  9. package/dist/constants/thresholds.d.ts +39 -0
  10. package/dist/constants/thresholds.js +54 -0
  11. package/dist/index.d.ts +20 -0
  12. package/dist/index.js +711 -0
  13. package/dist/services/burst.service.d.ts +39 -0
  14. package/dist/services/burst.service.js +215 -0
  15. package/dist/services/coaching.service.d.ts +38 -0
  16. package/dist/services/coaching.service.js +258 -0
  17. package/dist/services/consolidate.service.d.ts +17 -0
  18. package/dist/services/consolidate.service.js +236 -0
  19. package/dist/services/context.service.d.ts +15 -0
  20. package/dist/services/context.service.js +113 -0
  21. package/dist/services/export.service.d.ts +33 -0
  22. package/dist/services/export.service.js +129 -0
  23. package/dist/services/insights.service.d.ts +103 -0
  24. package/dist/services/insights.service.js +216 -0
  25. package/dist/services/logic.service.d.ts +28 -0
  26. package/dist/services/logic.service.js +467 -0
  27. package/dist/services/nudge.service.d.ts +20 -0
  28. package/dist/services/nudge.service.js +114 -0
  29. package/dist/services/recall.service.d.ts +38 -0
  30. package/dist/services/recall.service.js +188 -0
  31. package/dist/services/stagnation.service.d.ts +14 -0
  32. package/dist/services/stagnation.service.js +48 -0
  33. package/dist/services/thinking.service.d.ts +263 -0
  34. package/dist/services/thinking.service.js +1048 -0
  35. package/dist/services/validation.service.d.ts +45 -0
  36. package/dist/services/validation.service.js +260 -0
  37. package/dist/services/visualization.service.d.ts +23 -0
  38. package/dist/services/visualization.service.js +211 -0
  39. package/dist/types/thought.types.d.ts +486 -0
  40. package/dist/types/thought.types.js +5 -0
  41. package/dist/utils/index.d.ts +6 -0
  42. package/dist/utils/index.js +6 -0
  43. package/dist/utils/sensitive-data.d.ts +2 -0
  44. package/dist/utils/sensitive-data.js +28 -0
  45. package/dist/utils/storage-paths.d.ts +9 -0
  46. package/dist/utils/storage-paths.js +28 -0
  47. package/dist/utils/text-analysis.d.ts +30 -0
  48. package/dist/utils/text-analysis.js +92 -0
  49. package/package.json +66 -0
@@ -0,0 +1,92 @@
1
+ /**
2
+ * Text analysis utilities for ThinkingService
3
+ * Pure stateless functions for text processing
4
+ * v4.7.1 - Fixed RegExp escape pattern
5
+ */
6
+ import { FILLER_PHRASES, TECHNICAL_SHORT_TERMS } from '../constants/index.js';
7
+ // Precompiled RegExp for filler phrases (O(1) instead of O(n) per call)
8
+ const FILLER_PATTERN = new RegExp(FILLER_PHRASES.map(p => p.replace(/[.*+?^${}()|[\]\\]/g, String.raw `\$&`)).join('|'), 'gi');
9
+ // Word cache for Jaccard similarity (LRU-style with size limit)
10
+ const WORD_CACHE_LIMIT = 50;
11
+ const wordCache = new Map();
12
+ /**
13
+ * Clear word cache (call on session reset if needed)
14
+ */
15
+ export function clearWordCache() {
16
+ wordCache.clear();
17
+ }
18
+ /**
19
+ * Normalize text for stagnation comparison
20
+ * Uses precompiled RegExp for O(n) instead of O(n*m)
21
+ */
22
+ export function normalizeForComparison(text) {
23
+ return text
24
+ .toLowerCase()
25
+ .replace(FILLER_PATTERN, '')
26
+ .replace(/\s+/g, ' ')
27
+ .trim();
28
+ }
29
+ /**
30
+ * Calculate word entropy (diversity) of text
31
+ * Returns 0-1, higher = more diverse vocabulary
32
+ * Includes technical short terms (api, db, etc.) that would otherwise be filtered
33
+ */
34
+ export function calculateWordEntropy(text) {
35
+ const words = text.toLowerCase().split(/\s+/).filter((w) => w.length > 2 || TECHNICAL_SHORT_TERMS.has(w));
36
+ if (words.length === 0)
37
+ return 0;
38
+ const uniqueWords = new Set(words);
39
+ return uniqueWords.size / words.length;
40
+ }
41
+ /**
42
+ * Get word set from text with caching
43
+ * Uses LRU-style cache to avoid repeated parsing
44
+ */
45
+ function getWordSet(text) {
46
+ // Check cache first
47
+ const cached = wordCache.get(text);
48
+ if (cached)
49
+ return cached;
50
+ // Parse words
51
+ const words = new Set(normalizeForComparison(text)
52
+ .split(/\s+/)
53
+ .filter(w => w.length > 2 || TECHNICAL_SHORT_TERMS.has(w.toLowerCase())));
54
+ // LRU eviction if cache full
55
+ if (wordCache.size >= WORD_CACHE_LIMIT) {
56
+ const firstKey = wordCache.keys().next().value;
57
+ if (firstKey)
58
+ wordCache.delete(firstKey);
59
+ }
60
+ wordCache.set(text, words);
61
+ return words;
62
+ }
63
+ /**
64
+ * Calculate Jaccard similarity (0-1) between two texts
65
+ * Uses cached word sets for repeated comparisons
66
+ */
67
+ export function calculateJaccardSimilarity(text1, text2) {
68
+ const words1 = getWordSet(text1);
69
+ const words2 = getWordSet(text2);
70
+ if (words1.size === 0 || words2.size === 0)
71
+ return 0;
72
+ const intersection = [...words1].filter(w => words2.has(w)).length;
73
+ const union = new Set([...words1, ...words2]).size;
74
+ return union > 0 ? intersection / union : 0;
75
+ }
76
+ /**
77
+ * Sanitize text for safe Mermaid.js rendering
78
+ * Escapes special characters that could break diagram syntax
79
+ */
80
+ export function sanitizeForMermaid(text) {
81
+ return text
82
+ .replace(/"/g, "'")
83
+ .replace(/\[/g, '(')
84
+ .replace(/\]/g, ')')
85
+ .replace(/\{/g, '(')
86
+ .replace(/\}/g, ')')
87
+ .replace(/-->/g, '->')
88
+ .replace(/---/g, '--')
89
+ .replace(/</g, '‹')
90
+ .replace(/>/g, '›')
91
+ .replace(/\|/g, '¦');
92
+ }
package/package.json ADDED
@@ -0,0 +1,66 @@
1
+ {
2
+ "name": "@felkot/think-mcp",
3
+ "version": "1.1.0",
4
+ "type": "module",
5
+ "description": "MCP Server for structured sequential thinking with Burst Thinking, Logic Methodology Generator, branching, revisions, dead-ends tracking, and fuzzy recall",
6
+ "author": "FelKot",
7
+ "license": "MIT",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "git+https://github.com/FelKot/think-mcp.git"
11
+ },
12
+ "homepage": "https://github.com/FelKot/think-mcp#readme",
13
+ "bugs": {
14
+ "url": "https://github.com/FelKot/think-mcp/issues"
15
+ },
16
+ "keywords": [
17
+ "mcp",
18
+ "model-context-protocol",
19
+ "thinking",
20
+ "reasoning",
21
+ "ai",
22
+ "llm",
23
+ "sequential-thinking",
24
+ "claude",
25
+ "anthropic"
26
+ ],
27
+ "main": "dist/index.js",
28
+ "bin": {
29
+ "think-mcp": "dist/index.js"
30
+ },
31
+ "files": [
32
+ "dist",
33
+ "README.md",
34
+ "LICENSE"
35
+ ],
36
+ "scripts": {
37
+ "build": "npm run clean && tsc",
38
+ "prepublishOnly": "npm run build",
39
+ "start": "node dist/index.js",
40
+ "dev": "tsx src/index.ts",
41
+ "clean": "node clean.mjs",
42
+ "typecheck": "tsc --noEmit",
43
+ "test": "vitest run",
44
+ "test:watch": "vitest",
45
+ "test:coverage": "vitest run --coverage",
46
+ "audit:prod": "npm audit --omit=dev --audit-level=high"
47
+ },
48
+ "dependencies": {
49
+ "@modelcontextprotocol/sdk": "^1.27.0",
50
+ "fuse.js": "^7.1.0",
51
+ "zod": "^3.23.0"
52
+ },
53
+ "overrides": {
54
+ "ajv": "8.18.0"
55
+ },
56
+ "devDependencies": {
57
+ "@types/node": "^20.0.0",
58
+ "@vitest/coverage-v8": "^4.0.18",
59
+ "tsx": "^4.0.0",
60
+ "typescript": "^5.0.0",
61
+ "vitest": "^4.0.16"
62
+ },
63
+ "engines": {
64
+ "node": ">=18.0.0"
65
+ }
66
+ }