@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,486 @@
1
+ /**
2
+ * Type definitions for sequential thinking module
3
+ * Version 3.3.0 - Memory Edition
4
+ */
5
+ export type ExtensionType = 'critique' | 'elaboration' | 'correction' | 'alternative_scenario' | 'assumption_testing' | 'innovation' | 'optimization' | 'polish';
6
+ export type ImpactLevel = 'high' | 'medium' | 'low' | 'blocker';
7
+ /** Metadata attached by server for internal tracking */
8
+ export interface ThoughtMetadata {
9
+ /** True if thought was auto-corrected by system */
10
+ wasAutoCorrected?: boolean;
11
+ /** Normalized word entropy (0-1, higher = more diverse) */
12
+ normalizedEntropy?: number;
13
+ /** Processing time in milliseconds */
14
+ processingTimeMs?: number;
15
+ }
16
+ export interface ThoughtExtension {
17
+ type: ExtensionType;
18
+ content: string;
19
+ impact: ImpactLevel;
20
+ timestamp: string;
21
+ }
22
+ export interface ExtendThoughtInput {
23
+ targetThoughtNumber: number;
24
+ extensionType: ExtensionType;
25
+ content: string;
26
+ impactOnFinalResult: ImpactLevel;
27
+ }
28
+ export interface ExtendThoughtResult {
29
+ status: 'success' | 'error';
30
+ targetThought?: string;
31
+ totalExtensionsOnThisThought?: number;
32
+ systemAdvice: string;
33
+ errorMessage?: string;
34
+ }
35
+ export type ThoughtPhase = 'initialization' | 'analysis' | 'strategy' | 'execution' | 'verification' | 'conclusion';
36
+ export interface ThoughtInput {
37
+ thought: string;
38
+ nextThoughtNeeded: boolean;
39
+ thoughtNumber: number;
40
+ totalThoughts: number;
41
+ /** The cognitive phase of this thought */
42
+ phase?: ThoughtPhase;
43
+ /** Files actively being analyzed or modified */
44
+ context_files?: string[];
45
+ isRevision?: boolean;
46
+ revisesThought?: number;
47
+ branchFromThought?: number;
48
+ branchId?: string;
49
+ /** Confidence score (1-10) for this thought step */
50
+ confidence?: number;
51
+ /** Micro-steps: detailed action plan within this thought (max 5) */
52
+ subSteps?: string[];
53
+ /** Quick alternatives comparison without creating branches */
54
+ alternatives?: string[];
55
+ /** Session goal - set in first thought to maintain focus (v2.10.0) */
56
+ goal?: string;
57
+ /** Quick extension - add critique/elaboration inline without separate tool call (v3.1.0) */
58
+ quickExtension?: QuickExtension;
59
+ /** Show ASCII tree in response (v3.2.0) - default false to save tokens */
60
+ showTree?: boolean;
61
+ /** Include captured file content in tool response (default false) */
62
+ includeContextContent?: boolean;
63
+ }
64
+ export interface FileSnapshot {
65
+ path: string;
66
+ content: string;
67
+ timestamp: number;
68
+ error?: string;
69
+ }
70
+ export interface ThoughtRecord extends ThoughtInput {
71
+ timestamp: number;
72
+ extensions?: ThoughtExtension[];
73
+ /** Server-attached metadata for tracking and analysis */
74
+ metadata?: ThoughtMetadata;
75
+ /** Session identifier for isolation (v2.11.0) */
76
+ sessionId?: string;
77
+ /** Snapshots of files referenced in context_files */
78
+ context_snapshots?: FileSnapshot[];
79
+ }
80
+ export interface ThoughtSummary {
81
+ thoughtNumber: number;
82
+ thought: string;
83
+ confidence?: number;
84
+ }
85
+ export interface ValidationResult {
86
+ valid: boolean;
87
+ warning?: string;
88
+ }
89
+ export interface ThinkingResult {
90
+ [key: string]: unknown;
91
+ thoughtNumber: number;
92
+ totalThoughts: number;
93
+ nextThoughtNeeded: boolean;
94
+ branches: string[];
95
+ thoughtHistoryLength: number;
96
+ /** Summary of last 3 thoughts for context retention */
97
+ contextSummary: ThoughtSummary[];
98
+ /** ASCII tree visualization of thought structure */
99
+ thoughtTree: string;
100
+ /** Mermaid.js graph visualization */
101
+ thoughtTreeMermaid?: string;
102
+ /** Validation warning if sequence was broken */
103
+ warning?: string;
104
+ /** Average confidence across all thoughts */
105
+ averageConfidence?: number;
106
+ /** System advice for improving thinking process */
107
+ systemAdvice?: string;
108
+ /** Error flag - if true, thought was rejected */
109
+ isError?: boolean;
110
+ /** Error message when isError is true */
111
+ errorMessage?: string;
112
+ /** Session goal for focus retention (v2.10.0) */
113
+ sessionGoal?: string;
114
+ /** Proactive micro-prompt for self-reflection (v4.6.0) */
115
+ nudge?: string;
116
+ /** Detailed content of context files read during this step (v5.4.0) */
117
+ contextDetails?: string;
118
+ /** True when contextDetails was truncated for safety */
119
+ contextDetailsTruncated?: boolean;
120
+ }
121
+ /** Session data for persistence */
122
+ export interface SessionData {
123
+ history: ThoughtRecord[];
124
+ branches: [string, ThoughtRecord[]][];
125
+ lastThoughtNumber: number;
126
+ savedAt: string;
127
+ }
128
+ /** Verdict for consolidation */
129
+ export type ConsolidateVerdict = 'ready' | 'needs_more_work';
130
+ /** Quick extension for inline deep-dive (v3.1.0) */
131
+ export interface QuickExtension {
132
+ type: ExtensionType;
133
+ content: string;
134
+ impact?: ImpactLevel;
135
+ }
136
+ /** Input for think_done tool */
137
+ export interface ConsolidateInput {
138
+ winningPath: number[];
139
+ summary: string;
140
+ constraintCheck?: string;
141
+ potentialFlaws?: string;
142
+ verdict: ConsolidateVerdict;
143
+ }
144
+ /** Result from think_done consolidation */
145
+ export interface ConsolidateResult {
146
+ status: 'success' | 'error';
147
+ evaluation: string;
148
+ warnings: string[];
149
+ canProceedToFinalAnswer: boolean;
150
+ pathAnalysis: {
151
+ totalThoughts: number;
152
+ pathLength: number;
153
+ ignoredRatio: number;
154
+ lowConfidenceInPath: number[];
155
+ unaddressedBlockers: number[];
156
+ /** Thoughts with high/blocker critique extensions without revision */
157
+ unaddressedCritical: number[];
158
+ /** Path connectivity issues (disconnected thoughts) */
159
+ disconnectedAt?: number[];
160
+ };
161
+ errorMessage?: string;
162
+ }
163
+ /** Result of path connectivity validation */
164
+ export interface PathConnectivityResult {
165
+ valid: boolean;
166
+ error?: string;
167
+ disconnectedAt?: number;
168
+ }
169
+ /** Export options used by think_done */
170
+ export interface ExportSessionOptions {
171
+ format?: 'markdown' | 'json';
172
+ includeMermaid?: boolean;
173
+ }
174
+ /** Session data extended with goal (v2.10.0) */
175
+ export interface SessionDataV2 extends SessionData {
176
+ goal?: string;
177
+ /** Current session ID for isolation (v2.11.0) */
178
+ currentSessionId?: string;
179
+ }
180
+ /** Dead end - a path that was rejected (v3.3.0) */
181
+ export interface DeadEnd {
182
+ /** The path that led to a dead end */
183
+ path: number[];
184
+ /** Reason why this path was rejected */
185
+ reason: string;
186
+ /** When this dead end was recorded */
187
+ timestamp: string;
188
+ /** Session ID for isolation */
189
+ sessionId?: string;
190
+ }
191
+ /** Session data with dead ends tracking (v3.3.0) */
192
+ export interface SessionDataV3 extends SessionDataV2 {
193
+ /** Paths that were rejected and should be avoided */
194
+ deadEnds?: DeadEnd[];
195
+ }
196
+ /** Search scope for recall_thought */
197
+ export type RecallScope = 'current' | 'all';
198
+ /** Content type filter for recall_thought */
199
+ export type RecallSearchIn = 'thoughts' | 'extensions' | 'alternatives' | 'all';
200
+ /** Input for recall_thought tool (v3.4.0) */
201
+ export interface RecallInput {
202
+ /** Search query - supports fuzzy matching */
203
+ query: string;
204
+ /** Search scope: 'current' session or 'all' history */
205
+ scope?: RecallScope;
206
+ /** Where to search: thoughts, extensions, alternatives, or all */
207
+ searchIn?: RecallSearchIn;
208
+ /** Maximum results to return (default: 3) */
209
+ limit?: number;
210
+ /** Fuse.js threshold 0-1, lower = stricter match (default: 0.4) */
211
+ threshold?: number;
212
+ }
213
+ /** Single match from recall_thought */
214
+ export interface RecallMatch {
215
+ /** Thought number where match was found */
216
+ thoughtNumber: number;
217
+ /** Snippet with context around the match */
218
+ snippet: string;
219
+ /** Full thought text (truncated if too long) */
220
+ thought: string;
221
+ /** Confidence score of the original thought */
222
+ confidence?: number;
223
+ /** Relevance score from Fuse.js (0-1, lower = better match) */
224
+ relevance: number;
225
+ /** Where the match was found */
226
+ matchedIn: 'thought' | 'extension' | 'alternative' | 'subStep';
227
+ /** Extension type if matched in extension */
228
+ extensionType?: ExtensionType;
229
+ /** Session ID for context */
230
+ sessionId?: string;
231
+ }
232
+ /** Result from recall_thought tool */
233
+ export interface RecallResult {
234
+ /** Array of matching thoughts with snippets */
235
+ matches: RecallMatch[];
236
+ /** Total thoughts searched */
237
+ totalSearched: number;
238
+ /** Original query */
239
+ query: string;
240
+ /** Search parameters used */
241
+ searchParams: {
242
+ scope: RecallScope;
243
+ searchIn: RecallSearchIn;
244
+ threshold: number;
245
+ };
246
+ }
247
+ /** Single thought in a burst session */
248
+ export interface BurstThought {
249
+ thoughtNumber: number;
250
+ thought: string;
251
+ confidence?: number;
252
+ subSteps?: string[];
253
+ alternatives?: string[];
254
+ isRevision?: boolean;
255
+ revisesThought?: number;
256
+ branchFromThought?: number;
257
+ branchId?: string;
258
+ extensions?: QuickExtension[];
259
+ }
260
+ /** Consolidation data for burst session */
261
+ export interface BurstConsolidation {
262
+ winningPath: number[];
263
+ summary: string;
264
+ verdict: ConsolidateVerdict;
265
+ }
266
+ /** Input for submit_thinking_session tool */
267
+ export interface SubmitSessionInput {
268
+ /** Session goal - required for burst thinking */
269
+ goal: string;
270
+ /** Array of thoughts (1-30) */
271
+ thoughts: BurstThought[];
272
+ /** Optional consolidation if ready */
273
+ consolidation?: BurstConsolidation;
274
+ }
275
+ /** Validation metrics for burst session */
276
+ export interface BurstMetrics {
277
+ avgConfidence: number;
278
+ avgEntropy: number;
279
+ avgLength: number;
280
+ stagnationScore: number;
281
+ thoughtCount: number;
282
+ }
283
+ /** Validation result for burst session */
284
+ export interface BurstValidation {
285
+ passed: boolean;
286
+ errors: string[];
287
+ warnings: string[];
288
+ }
289
+ /** Result from submit_thinking_session tool */
290
+ export interface SubmitSessionResult {
291
+ status: 'accepted' | 'rejected';
292
+ sessionId: string;
293
+ thoughtsProcessed: number;
294
+ validation: BurstValidation;
295
+ metrics: BurstMetrics;
296
+ thoughtTree?: string;
297
+ systemAdvice?: string;
298
+ errorMessage?: string;
299
+ /** Proactive micro-prompt for self-reflection (v4.6.0) */
300
+ nudge?: string;
301
+ }
302
+ /** Input for recall_insights tool */
303
+ export interface RecallInsightsInput {
304
+ /** Search query for finding relevant past solutions */
305
+ query: string;
306
+ /** Maximum results to return (default: 3) */
307
+ limit?: number;
308
+ }
309
+ /** Result from recall_insights tool */
310
+ export interface RecallInsightsResult {
311
+ /** Matching insights from past sessions */
312
+ matches: {
313
+ /** Summary of the past solution */
314
+ summary: string;
315
+ /** Goal that was achieved */
316
+ goal?: string;
317
+ /** Keywords associated with this insight */
318
+ keywords: string[];
319
+ /** When this insight was recorded */
320
+ timestamp: string;
321
+ /** Relevance score (0-1, lower = better match) */
322
+ relevance: number;
323
+ }[];
324
+ /** Total insights in storage */
325
+ totalInsights: number;
326
+ /** Top recurring patterns */
327
+ topPatterns: {
328
+ keyword: string;
329
+ count: number;
330
+ }[];
331
+ }
332
+ /** Analysis depth for think_logic */
333
+ export type LogicDepth = 'quick' | 'standard' | 'deep';
334
+ /** Focus areas for think_logic */
335
+ export type LogicFocus = 'security' | 'performance' | 'reliability' | 'ux' | 'architecture' | 'data-flow' | 'testing';
336
+ /** Severity levels for identified cracks */
337
+ export type CrackSeverity = 'blocker' | 'high' | 'medium' | 'low';
338
+ /** Priority levels for action items */
339
+ export type ActionPriority = 'P0' | 'P1' | 'P2' | 'P3';
340
+ /** Risk levels for implementation planning */
341
+ export type RiskLevel = 'low' | 'medium' | 'high';
342
+ /** Supported tech stacks for stack-aware analysis */
343
+ export type TechStack = 'nestjs' | 'prisma' | 'ts-rest' | 'react' | 'redis' | 'zod' | 'trpc' | 'nextjs' | 'drizzle' | 'hono';
344
+ /** Input for think_logic tool */
345
+ export interface LogicAnalysisInput {
346
+ /** What to analyze (feature, flow, component, system) */
347
+ target: string;
348
+ /** Additional context (tech stack, constraints, requirements) */
349
+ context?: string;
350
+ /** Analysis depth: quick (overview), standard (detailed), deep (exhaustive) */
351
+ depth?: LogicDepth;
352
+ /** Focus areas to prioritize in analysis */
353
+ focus?: LogicFocus[];
354
+ /** Tech stacks to apply stack-specific checks (v4.8.0) */
355
+ stack?: TechStack[];
356
+ /** Show chain map section */
357
+ showChain?: boolean;
358
+ /** Show cracks section */
359
+ showCracks?: boolean;
360
+ /** Show luxury standard section */
361
+ showStandard?: boolean;
362
+ /** Show action items section */
363
+ showActions?: boolean;
364
+ }
365
+ /** Single step in the logic chain */
366
+ export interface LogicChainStep {
367
+ /** Step number in sequence */
368
+ step: number;
369
+ /** Step name/title */
370
+ name: string;
371
+ /** What happens at this step */
372
+ description: string;
373
+ /** Components/systems involved */
374
+ components?: string[];
375
+ /** Data transformations */
376
+ dataFlow?: string;
377
+ }
378
+ /** Identified crack/weakness in the logic */
379
+ export interface LogicCrack {
380
+ /** Unique identifier */
381
+ id: string;
382
+ /** Severity level */
383
+ severity: CrackSeverity;
384
+ /** Which chain step this affects */
385
+ affectsStep?: number;
386
+ /** Category of the crack */
387
+ category: string;
388
+ /** Description of the issue */
389
+ description: string;
390
+ /** Potential impact if not addressed */
391
+ impact: string;
392
+ /** Related focus area */
393
+ focus?: LogicFocus;
394
+ /** Possible root causes (v4.8.0 - WHY analysis) */
395
+ possibleCauses?: string[];
396
+ /** Debug steps to investigate (v4.8.0) */
397
+ debugSteps?: string[];
398
+ /** Stack-specific if detected from tech stack */
399
+ fromStack?: string;
400
+ }
401
+ /** Luxury standard benchmark item */
402
+ export interface LogicStandard {
403
+ /** Standard category */
404
+ category: string;
405
+ /** What the standard requires */
406
+ requirement: string;
407
+ /** Current state assessment */
408
+ currentState: 'met' | 'partial' | 'missing' | 'unknown';
409
+ /** Gap description if not fully met */
410
+ gap?: string;
411
+ }
412
+ /** Action item for improvement */
413
+ export interface LogicActionItem {
414
+ /** Unique identifier */
415
+ id: string;
416
+ /** Priority level */
417
+ priority: ActionPriority;
418
+ /** Action title */
419
+ title: string;
420
+ /** Detailed description */
421
+ description: string;
422
+ /** Which crack this addresses */
423
+ addressesCrack?: string;
424
+ /** Estimated effort */
425
+ effort?: 'trivial' | 'small' | 'medium' | 'large';
426
+ }
427
+ /** Priority item for practical execution plan */
428
+ export interface LogicPriorityItem {
429
+ /** Priority bucket */
430
+ priority: 'P0' | 'P1' | 'P2';
431
+ /** What to implement/check */
432
+ objective: string;
433
+ /** Why this is important */
434
+ rationale: string;
435
+ /** Delivery risk */
436
+ risk: RiskLevel;
437
+ /** Estimated implementation effort */
438
+ effort: 'small' | 'medium' | 'large';
439
+ /** Minimal proof that item is complete */
440
+ verify: string;
441
+ }
442
+ /** Result from think_logic tool - v5.0.0 Methodology Edition */
443
+ export interface LogicAnalysisResult {
444
+ /** Analysis status */
445
+ status: 'success' | 'error';
446
+ /** Target that was analyzed */
447
+ target: string;
448
+ /** Depth used */
449
+ depth: LogicDepth;
450
+ /** Focus areas applied */
451
+ focus: LogicFocus[];
452
+ /** Tech stacks applied */
453
+ stack?: TechStack[];
454
+ /** Generated methodology for AI to follow */
455
+ methodology?: LogicMethodology;
456
+ /** Warnings during analysis */
457
+ warnings: string[];
458
+ /** Error message if status is error */
459
+ errorMessage?: string;
460
+ }
461
+ /** Single section in the methodology */
462
+ export interface MethodologySection {
463
+ /** Section title with emoji */
464
+ title: string;
465
+ /** Purpose of this phase */
466
+ purpose: string;
467
+ /** Instructions/questions for AI to follow */
468
+ content: string[];
469
+ }
470
+ /** Methodology structure - instructions for AI, not analysis results */
471
+ export interface LogicMethodology {
472
+ /** Task description */
473
+ task: string;
474
+ /** Methodology sections (phases) */
475
+ sections: MethodologySection[];
476
+ /** Recommended execution order */
477
+ executionOrder?: string[];
478
+ /** Prioritized action plan */
479
+ priorityPlan?: LogicPriorityItem[];
480
+ /** Definition-of-done verification checklist */
481
+ verifyChecklist?: string[];
482
+ /** Pre-mortem risks and fallback ideas */
483
+ preMortem?: string[];
484
+ /** Stack-specific reminders (optional) */
485
+ stackReminders?: string[];
486
+ }
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Type definitions for sequential thinking module
3
+ * Version 3.3.0 - Memory Edition
4
+ */
5
+ export {};
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Utils barrel export
3
+ */
4
+ export * from './text-analysis.js';
5
+ export * from './storage-paths.js';
6
+ export * from './sensitive-data.js';
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Utils barrel export
3
+ */
4
+ export * from './text-analysis.js';
5
+ export * from './storage-paths.js';
6
+ export * from './sensitive-data.js';
@@ -0,0 +1,2 @@
1
+ export declare function redactSensitiveContent(content: string): string;
2
+ export declare function isSensitiveFilePath(filePath: string): boolean;
@@ -0,0 +1,28 @@
1
+ import { basename } from 'path';
2
+ const SENSITIVE_VALUE_PATTERNS = [
3
+ /((?:api[_-]?key|token|secret|password|passwd|client[_-]?secret)\s*[:=]\s*["']?)[^\s"',;]+(["']?)/gi,
4
+ /(\bBearer\s+)[A-Za-z0-9._\-+/=]+/gi,
5
+ /\b(?:ghp|gho|github_pat|xoxb|xoxp|sk_live|sk_test|pk_live|pk_test|AKIA)[A-Za-z0-9_\-]{8,}\b/g,
6
+ /\bAIza[0-9A-Za-z\-_]{20,}\b/g,
7
+ /\beyJ[A-Za-z0-9_\-.]+\.[A-Za-z0-9_\-.]+\.[A-Za-z0-9_\-.]+\b/g
8
+ ];
9
+ const SENSITIVE_FILE_PATTERNS = [
10
+ /^\.env(?:\..+)?$/i,
11
+ /^id_(?:rsa|ed25519|ecdsa)$/i,
12
+ /\.(?:pem|p12|pfx|key|kdbx)$/i,
13
+ /(?:^|[-_.])(credentials|secret|secrets|private)(?:[-_.]|$)/i,
14
+ /service[-_.]?account.*\.json$/i
15
+ ];
16
+ export function redactSensitiveContent(content) {
17
+ let redacted = content;
18
+ redacted = redacted.replace(SENSITIVE_VALUE_PATTERNS[0], '$1[REDACTED]$2');
19
+ redacted = redacted.replace(SENSITIVE_VALUE_PATTERNS[1], '$1[REDACTED]');
20
+ redacted = redacted.replace(SENSITIVE_VALUE_PATTERNS[2], '[REDACTED_TOKEN]');
21
+ redacted = redacted.replace(SENSITIVE_VALUE_PATTERNS[3], '[REDACTED_TOKEN]');
22
+ redacted = redacted.replace(SENSITIVE_VALUE_PATTERNS[4], '[REDACTED_JWT]');
23
+ return redacted;
24
+ }
25
+ export function isSensitiveFilePath(filePath) {
26
+ const fileName = basename(filePath).toLowerCase();
27
+ return SENSITIVE_FILE_PATTERNS.some((pattern) => pattern.test(fileName));
28
+ }
@@ -0,0 +1,9 @@
1
+ export interface ThinkStoragePaths {
2
+ rootDir: string;
3
+ thinkDir: string;
4
+ sessionsDir: string;
5
+ latestSessionFile: string;
6
+ insightsFile: string;
7
+ legacyInsightsFile: string;
8
+ }
9
+ export declare function getThinkStoragePaths(importMetaUrl: string): ThinkStoragePaths;
@@ -0,0 +1,28 @@
1
+ import { dirname, join, resolve } from 'path';
2
+ import { fileURLToPath } from 'url';
3
+ const STORAGE_DIR_NAME = '.think';
4
+ const STORAGE_OVERRIDE_ENV = 'THINK_MCP_STORAGE_DIR';
5
+ function resolveRootDir() {
6
+ const overrideDir = process.env[STORAGE_OVERRIDE_ENV]?.trim();
7
+ if (overrideDir) {
8
+ return resolve(overrideDir);
9
+ }
10
+ return resolve(process.cwd());
11
+ }
12
+ export function getThinkStoragePaths(importMetaUrl) {
13
+ const rootDir = resolveRootDir();
14
+ const thinkDir = join(rootDir, STORAGE_DIR_NAME);
15
+ const sessionsDir = join(thinkDir, 'sessions');
16
+ const latestSessionFile = join(sessionsDir, 'latest_session.json');
17
+ const insightsFile = join(thinkDir, 'insights.json');
18
+ const serviceDir = dirname(fileURLToPath(importMetaUrl));
19
+ const legacyInsightsFile = join(serviceDir, '..', '..', 'insights.json');
20
+ return {
21
+ rootDir,
22
+ thinkDir,
23
+ sessionsDir,
24
+ latestSessionFile,
25
+ insightsFile,
26
+ legacyInsightsFile
27
+ };
28
+ }
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Text analysis utilities for ThinkingService
3
+ * Pure stateless functions for text processing
4
+ * v4.7.1 - Fixed RegExp escape pattern
5
+ */
6
+ /**
7
+ * Clear word cache (call on session reset if needed)
8
+ */
9
+ export declare function clearWordCache(): void;
10
+ /**
11
+ * Normalize text for stagnation comparison
12
+ * Uses precompiled RegExp for O(n) instead of O(n*m)
13
+ */
14
+ export declare function normalizeForComparison(text: string): string;
15
+ /**
16
+ * Calculate word entropy (diversity) of text
17
+ * Returns 0-1, higher = more diverse vocabulary
18
+ * Includes technical short terms (api, db, etc.) that would otherwise be filtered
19
+ */
20
+ export declare function calculateWordEntropy(text: string): number;
21
+ /**
22
+ * Calculate Jaccard similarity (0-1) between two texts
23
+ * Uses cached word sets for repeated comparisons
24
+ */
25
+ export declare function calculateJaccardSimilarity(text1: string, text2: string): number;
26
+ /**
27
+ * Sanitize text for safe Mermaid.js rendering
28
+ * Escapes special characters that could break diagram syntax
29
+ */
30
+ export declare function sanitizeForMermaid(text: string): string;