gthinking 1.3.0 → 2.1.1
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/.eslintrc.js +34 -0
- package/ANALYSIS_SUMMARY.md +363 -0
- package/README.md +230 -250
- package/dist/analysis/analysis-engine.d.ts +63 -0
- package/dist/analysis/analysis-engine.d.ts.map +1 -0
- package/dist/analysis/analysis-engine.js +322 -0
- package/dist/analysis/analysis-engine.js.map +1 -0
- package/dist/core/config.d.ts +1419 -0
- package/dist/core/config.d.ts.map +1 -0
- package/dist/core/config.js +361 -0
- package/dist/core/config.js.map +1 -0
- package/dist/core/engine.d.ts +176 -0
- package/dist/core/engine.d.ts.map +1 -0
- package/dist/core/engine.js +604 -0
- package/dist/core/engine.js.map +1 -0
- package/dist/core/errors.d.ts +153 -0
- package/dist/core/errors.d.ts.map +1 -0
- package/dist/core/errors.js +287 -0
- package/dist/core/errors.js.map +1 -0
- package/dist/core/index.d.ts +7 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/{types.js → core/index.js} +8 -4
- package/dist/core/index.js.map +1 -0
- package/dist/core/pipeline.d.ts +121 -0
- package/dist/core/pipeline.d.ts.map +1 -0
- package/dist/core/pipeline.js +289 -0
- package/dist/core/pipeline.js.map +1 -0
- package/dist/core/rate-limiter.d.ts +58 -0
- package/dist/core/rate-limiter.d.ts.map +1 -0
- package/dist/core/rate-limiter.js +133 -0
- package/dist/core/rate-limiter.js.map +1 -0
- package/dist/core/session-manager.d.ts +96 -0
- package/dist/core/session-manager.d.ts.map +1 -0
- package/dist/core/session-manager.js +223 -0
- package/dist/core/session-manager.js.map +1 -0
- package/dist/creativity/creativity-engine.d.ts +6 -0
- package/dist/creativity/creativity-engine.d.ts.map +1 -0
- package/dist/creativity/creativity-engine.js +17 -0
- package/dist/creativity/creativity-engine.js.map +1 -0
- package/dist/index.d.ts +24 -32
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +130 -104
- package/dist/index.js.map +1 -1
- package/dist/learning/learning-engine.d.ts +6 -0
- package/dist/learning/learning-engine.d.ts.map +1 -0
- package/dist/learning/learning-engine.js +17 -0
- package/dist/learning/learning-engine.js.map +1 -0
- package/dist/llm/index.d.ts +10 -0
- package/dist/llm/index.d.ts.map +1 -0
- package/dist/llm/index.js +26 -0
- package/dist/llm/index.js.map +1 -0
- package/dist/llm/llm-service.d.ts +109 -0
- package/dist/llm/llm-service.d.ts.map +1 -0
- package/dist/llm/llm-service.js +224 -0
- package/dist/llm/llm-service.js.map +1 -0
- package/dist/llm/providers/base.d.ts +85 -0
- package/dist/llm/providers/base.d.ts.map +1 -0
- package/dist/llm/providers/base.js +57 -0
- package/dist/llm/providers/base.js.map +1 -0
- package/dist/llm/providers/cli.d.ts +23 -0
- package/dist/llm/providers/cli.d.ts.map +1 -0
- package/dist/llm/providers/cli.js +158 -0
- package/dist/llm/providers/cli.js.map +1 -0
- package/dist/llm/providers/gemini.d.ts +30 -0
- package/dist/llm/providers/gemini.d.ts.map +1 -0
- package/dist/llm/providers/gemini.js +168 -0
- package/dist/llm/providers/gemini.js.map +1 -0
- package/dist/llm/sanitization.d.ts +50 -0
- package/dist/llm/sanitization.d.ts.map +1 -0
- package/dist/llm/sanitization.js +149 -0
- package/dist/llm/sanitization.js.map +1 -0
- package/dist/{server.d.ts.map → mcp/server.d.ts.map} +1 -1
- package/dist/mcp/server.js +108 -0
- package/dist/mcp/server.js.map +1 -0
- package/dist/planning/planning-engine.d.ts +6 -0
- package/dist/planning/planning-engine.d.ts.map +1 -0
- package/dist/planning/planning-engine.js +17 -0
- package/dist/planning/planning-engine.js.map +1 -0
- package/dist/reasoning/reasoning-engine.d.ts +6 -0
- package/dist/reasoning/reasoning-engine.d.ts.map +1 -0
- package/dist/reasoning/reasoning-engine.js +17 -0
- package/dist/reasoning/reasoning-engine.js.map +1 -0
- package/dist/search/search-engine.d.ts +99 -0
- package/dist/search/search-engine.d.ts.map +1 -0
- package/dist/search/search-engine.js +271 -0
- package/dist/search/search-engine.js.map +1 -0
- package/dist/synthesis/synthesis-engine.d.ts +6 -0
- package/dist/synthesis/synthesis-engine.d.ts.map +1 -0
- package/dist/synthesis/synthesis-engine.js +17 -0
- package/dist/synthesis/synthesis-engine.js.map +1 -0
- package/dist/types/analysis.d.ts +1534 -49
- package/dist/types/analysis.d.ts.map +1 -1
- package/dist/types/analysis.js +250 -0
- package/dist/types/analysis.js.map +1 -1
- package/dist/types/core.d.ts +257 -30
- package/dist/types/core.d.ts.map +1 -1
- package/dist/types/core.js +148 -18
- package/dist/types/core.js.map +1 -1
- package/dist/types/creativity.d.ts +2871 -56
- package/dist/types/creativity.d.ts.map +1 -1
- package/dist/types/creativity.js +195 -0
- package/dist/types/creativity.js.map +1 -1
- package/dist/types/index.d.ts +6 -2
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +17 -2
- package/dist/types/index.js.map +1 -1
- package/dist/types/learning.d.ts +851 -61
- package/dist/types/learning.d.ts.map +1 -1
- package/dist/types/learning.js +155 -0
- package/dist/types/learning.js.map +1 -1
- package/dist/types/planning.d.ts +2223 -71
- package/dist/types/planning.d.ts.map +1 -1
- package/dist/types/planning.js +190 -0
- package/dist/types/planning.js.map +1 -1
- package/dist/types/reasoning.d.ts +2209 -72
- package/dist/types/reasoning.d.ts.map +1 -1
- package/dist/types/reasoning.js +200 -1
- package/dist/types/reasoning.js.map +1 -1
- package/dist/types/search.d.ts +981 -53
- package/dist/types/search.d.ts.map +1 -1
- package/dist/types/search.js +137 -0
- package/dist/types/search.js.map +1 -1
- package/dist/types/synthesis.d.ts +583 -38
- package/dist/types/synthesis.d.ts.map +1 -1
- package/dist/types/synthesis.js +138 -0
- package/dist/types/synthesis.js.map +1 -1
- package/dist/utils/cache.d.ts +144 -0
- package/dist/utils/cache.d.ts.map +1 -0
- package/dist/utils/cache.js +288 -0
- package/dist/utils/cache.js.map +1 -0
- package/dist/utils/id-generator.d.ts +89 -0
- package/dist/utils/id-generator.d.ts.map +1 -0
- package/dist/utils/id-generator.js +132 -0
- package/dist/utils/id-generator.js.map +1 -0
- package/dist/utils/index.d.ts +11 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +33 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/logger.d.ts +142 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +248 -0
- package/dist/utils/logger.js.map +1 -0
- package/dist/utils/metrics.d.ts +149 -0
- package/dist/utils/metrics.d.ts.map +1 -0
- package/dist/utils/metrics.js +296 -0
- package/dist/utils/metrics.js.map +1 -0
- package/dist/utils/timer.d.ts +7 -0
- package/dist/utils/timer.d.ts.map +1 -0
- package/dist/utils/timer.js +17 -0
- package/dist/utils/timer.js.map +1 -0
- package/dist/utils/validation.d.ts +147 -0
- package/dist/utils/validation.d.ts.map +1 -0
- package/dist/utils/validation.js +275 -0
- package/dist/utils/validation.js.map +1 -0
- package/docs/API.md +411 -0
- package/docs/ARCHITECTURE.md +271 -0
- package/docs/CHANGELOG.md +283 -0
- package/jest.config.js +28 -0
- package/package.json +43 -30
- package/src/analysis/analysis-engine.ts +383 -0
- package/src/core/config.ts +406 -0
- package/src/core/engine.ts +785 -0
- package/src/core/errors.ts +349 -0
- package/src/core/index.ts +12 -0
- package/src/core/pipeline.ts +424 -0
- package/src/core/rate-limiter.ts +155 -0
- package/src/core/session-manager.ts +269 -0
- package/src/creativity/creativity-engine.ts +14 -0
- package/src/index.ts +178 -0
- package/src/learning/learning-engine.ts +14 -0
- package/src/llm/index.ts +10 -0
- package/src/llm/llm-service.ts +285 -0
- package/src/llm/providers/base.ts +146 -0
- package/src/llm/providers/cli.ts +186 -0
- package/src/llm/providers/gemini.ts +201 -0
- package/src/llm/sanitization.ts +178 -0
- package/src/mcp/server.ts +117 -0
- package/src/planning/planning-engine.ts +14 -0
- package/src/reasoning/reasoning-engine.ts +14 -0
- package/src/search/search-engine.ts +333 -0
- package/src/synthesis/synthesis-engine.ts +14 -0
- package/src/types/analysis.ts +337 -0
- package/src/types/core.ts +342 -0
- package/src/types/creativity.ts +268 -0
- package/src/types/index.ts +31 -0
- package/src/types/learning.ts +215 -0
- package/src/types/planning.ts +251 -0
- package/src/types/reasoning.ts +288 -0
- package/src/types/search.ts +192 -0
- package/src/types/synthesis.ts +187 -0
- package/src/utils/cache.ts +363 -0
- package/src/utils/id-generator.ts +135 -0
- package/src/utils/index.ts +22 -0
- package/src/utils/logger.ts +290 -0
- package/src/utils/metrics.ts +380 -0
- package/src/utils/timer.ts +15 -0
- package/src/utils/validation.ts +297 -0
- package/tests/setup.ts +22 -0
- package/tests/unit/cache.test.ts +189 -0
- package/tests/unit/engine.test.ts +179 -0
- package/tests/unit/validation.test.ts +218 -0
- package/tsconfig.json +17 -12
- package/GEMINI.md +0 -68
- package/analysis.ts +0 -1063
- package/creativity.ts +0 -1055
- package/dist/analysis.d.ts +0 -54
- package/dist/analysis.d.ts.map +0 -1
- package/dist/analysis.js +0 -866
- package/dist/analysis.js.map +0 -1
- package/dist/creativity.d.ts +0 -81
- package/dist/creativity.d.ts.map +0 -1
- package/dist/creativity.js +0 -828
- package/dist/creativity.js.map +0 -1
- package/dist/engine.d.ts +0 -90
- package/dist/engine.d.ts.map +0 -1
- package/dist/engine.js +0 -720
- package/dist/engine.js.map +0 -1
- package/dist/examples.d.ts +0 -7
- package/dist/examples.d.ts.map +0 -1
- package/dist/examples.js +0 -506
- package/dist/examples.js.map +0 -1
- package/dist/learning.d.ts +0 -72
- package/dist/learning.d.ts.map +0 -1
- package/dist/learning.js +0 -615
- package/dist/learning.js.map +0 -1
- package/dist/llm-service.d.ts +0 -21
- package/dist/llm-service.d.ts.map +0 -1
- package/dist/llm-service.js +0 -100
- package/dist/llm-service.js.map +0 -1
- package/dist/planning.d.ts +0 -62
- package/dist/planning.d.ts.map +0 -1
- package/dist/planning.js +0 -886
- package/dist/planning.js.map +0 -1
- package/dist/reasoning.d.ts +0 -73
- package/dist/reasoning.d.ts.map +0 -1
- package/dist/reasoning.js +0 -845
- package/dist/reasoning.js.map +0 -1
- package/dist/search-discovery.d.ts +0 -73
- package/dist/search-discovery.d.ts.map +0 -1
- package/dist/search-discovery.js +0 -548
- package/dist/search-discovery.js.map +0 -1
- package/dist/server.js +0 -113
- package/dist/server.js.map +0 -1
- package/dist/types/engine.d.ts +0 -55
- package/dist/types/engine.d.ts.map +0 -1
- package/dist/types/engine.js +0 -3
- package/dist/types/engine.js.map +0 -1
- package/dist/types.d.ts +0 -6
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js.map +0 -1
- package/engine.ts +0 -1009
- package/examples.ts +0 -717
- package/index.ts +0 -106
- package/learning.ts +0 -779
- package/llm-service.ts +0 -120
- package/planning.ts +0 -1101
- package/reasoning.ts +0 -1079
- package/search-discovery.ts +0 -700
- package/server.ts +0 -115
- package/types/analysis.ts +0 -69
- package/types/core.ts +0 -90
- package/types/creativity.ts +0 -72
- package/types/engine.ts +0 -60
- package/types/index.ts +0 -9
- package/types/learning.ts +0 -69
- package/types/planning.ts +0 -85
- package/types/reasoning.ts +0 -92
- package/types/search.ts +0 -58
- package/types/synthesis.ts +0 -43
- package/types.ts +0 -6
- /package/dist/{server.d.ts → mcp/server.d.ts} +0 -0
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Unit Tests for Validation Utilities
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import {
|
|
6
|
+
sanitizeInput,
|
|
7
|
+
sanitizeForShell,
|
|
8
|
+
validateEmail,
|
|
9
|
+
isValidURL,
|
|
10
|
+
isNonEmptyString,
|
|
11
|
+
isPositiveInteger,
|
|
12
|
+
isInRange,
|
|
13
|
+
safeJsonParse,
|
|
14
|
+
safeJsonStringify,
|
|
15
|
+
validateSchema,
|
|
16
|
+
hasRequiredProperties,
|
|
17
|
+
isValidLength,
|
|
18
|
+
deepClone,
|
|
19
|
+
isPlainObject,
|
|
20
|
+
} from '../../src/utils/validation';
|
|
21
|
+
import { z } from 'zod';
|
|
22
|
+
|
|
23
|
+
describe('sanitizeInput', () => {
|
|
24
|
+
it('should remove HTML tags', () => {
|
|
25
|
+
expect(sanitizeInput('<script>alert("xss")</script>')).toBe('scriptalert"xss"/script');
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
it('should remove shell metacharacters', () => {
|
|
29
|
+
expect(sanitizeInput('test; rm -rf /')).toBe('test rm -rf /');
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
it('should handle empty strings', () => {
|
|
33
|
+
expect(sanitizeInput('')).toBe('');
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
it('should trim whitespace', () => {
|
|
37
|
+
expect(sanitizeInput(' test ')).toBe('test');
|
|
38
|
+
});
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
describe('sanitizeForShell', () => {
|
|
42
|
+
it('should remove dangerous characters', () => {
|
|
43
|
+
expect(sanitizeForShell('test; | & `')).toBe('test');
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
it('should allow safe characters', () => {
|
|
47
|
+
expect(sanitizeForShell('hello world_123')).toBe('hello world_123');
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
describe('validateEmail', () => {
|
|
52
|
+
it('should validate correct emails', () => {
|
|
53
|
+
expect(validateEmail('test@example.com')).toBe('test@example.com');
|
|
54
|
+
expect(validateEmail('user.name@domain.co.uk')).toBe('user.name@domain.co.uk');
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
it('should return null for invalid emails', () => {
|
|
58
|
+
expect(validateEmail('invalid')).toBeNull();
|
|
59
|
+
expect(validateEmail('@example.com')).toBeNull();
|
|
60
|
+
expect(validateEmail('test@')).toBeNull();
|
|
61
|
+
});
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
describe('isValidURL', () => {
|
|
65
|
+
it('should validate correct URLs', () => {
|
|
66
|
+
expect(isValidURL('https://example.com')).toBe(true);
|
|
67
|
+
expect(isValidURL('http://localhost:3000')).toBe(true);
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
it('should return false for invalid URLs', () => {
|
|
71
|
+
expect(isValidURL('not-a-url')).toBe(false);
|
|
72
|
+
expect(isValidURL('')).toBe(false);
|
|
73
|
+
});
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
describe('isNonEmptyString', () => {
|
|
77
|
+
it('should return true for non-empty strings', () => {
|
|
78
|
+
expect(isNonEmptyString('hello')).toBe(true);
|
|
79
|
+
expect(isNonEmptyString('a')).toBe(true);
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
it('should return false for empty or whitespace strings', () => {
|
|
83
|
+
expect(isNonEmptyString('')).toBe(false);
|
|
84
|
+
expect(isNonEmptyString(' ')).toBe(false);
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
it('should return false for non-strings', () => {
|
|
88
|
+
expect(isNonEmptyString(null)).toBe(false);
|
|
89
|
+
expect(isNonEmptyString(123)).toBe(false);
|
|
90
|
+
expect(isNonEmptyString(undefined)).toBe(false);
|
|
91
|
+
});
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
describe('isPositiveInteger', () => {
|
|
95
|
+
it('should return true for positive integers', () => {
|
|
96
|
+
expect(isPositiveInteger(1)).toBe(true);
|
|
97
|
+
expect(isPositiveInteger(100)).toBe(true);
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
it('should return false for non-positive integers', () => {
|
|
101
|
+
expect(isPositiveInteger(0)).toBe(false);
|
|
102
|
+
expect(isPositiveInteger(-1)).toBe(false);
|
|
103
|
+
expect(isPositiveInteger(1.5)).toBe(false);
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
it('should return false for non-numbers', () => {
|
|
107
|
+
expect(isPositiveInteger('1')).toBe(false);
|
|
108
|
+
expect(isPositiveInteger(null)).toBe(false);
|
|
109
|
+
});
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
describe('isInRange', () => {
|
|
113
|
+
it('should return true for values in range', () => {
|
|
114
|
+
expect(isInRange(5, 0, 10)).toBe(true);
|
|
115
|
+
expect(isInRange(0, 0, 10)).toBe(true);
|
|
116
|
+
expect(isInRange(10, 0, 10)).toBe(true);
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
it('should return false for values out of range', () => {
|
|
120
|
+
expect(isInRange(-1, 0, 10)).toBe(false);
|
|
121
|
+
expect(isInRange(11, 0, 10)).toBe(false);
|
|
122
|
+
});
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
describe('safeJsonParse', () => {
|
|
126
|
+
it('should parse valid JSON', () => {
|
|
127
|
+
const obj = { key: 'value' };
|
|
128
|
+
expect(safeJsonParse(JSON.stringify(obj))).toEqual(obj);
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
it('should return null for invalid JSON', () => {
|
|
132
|
+
expect(safeJsonParse('invalid json')).toBeNull();
|
|
133
|
+
});
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
describe('safeJsonStringify', () => {
|
|
137
|
+
it('should stringify valid objects', () => {
|
|
138
|
+
const obj = { key: 'value' };
|
|
139
|
+
expect(safeJsonStringify(obj)).toBe('{"key":"value"}');
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
it('should return null for circular references', () => {
|
|
143
|
+
const obj: Record<string, unknown> = { key: 'value' };
|
|
144
|
+
obj.circular = obj;
|
|
145
|
+
expect(safeJsonStringify(obj)).toBeNull();
|
|
146
|
+
});
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
describe('validateSchema', () => {
|
|
150
|
+
const TestSchema = z.object({
|
|
151
|
+
name: z.string(),
|
|
152
|
+
age: z.number().positive(),
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
it('should validate valid data', () => {
|
|
156
|
+
const data = { name: 'John', age: 30 };
|
|
157
|
+
expect(validateSchema(TestSchema, data)).toEqual(data);
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
it('should throw ValidationError for invalid data', () => {
|
|
161
|
+
const data = { name: 'John', age: -5 };
|
|
162
|
+
expect(() => validateSchema(TestSchema, data)).toThrow();
|
|
163
|
+
});
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
describe('hasRequiredProperties', () => {
|
|
167
|
+
it('should return true when all properties exist', () => {
|
|
168
|
+
const obj = { a: 1, b: 2, c: 3 };
|
|
169
|
+
expect(hasRequiredProperties(obj, ['a', 'b'])).toBe(true);
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
it('should return false when properties are missing', () => {
|
|
173
|
+
const obj: Record<string, any> = { a: 1 };
|
|
174
|
+
expect(hasRequiredProperties(obj, ['a', 'b'])).toBe(false);
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
it('should return false for undefined properties', () => {
|
|
178
|
+
const obj: Record<string, any> = { a: 1, b: undefined };
|
|
179
|
+
expect(hasRequiredProperties(obj, ['a', 'b'])).toBe(false);
|
|
180
|
+
});
|
|
181
|
+
});
|
|
182
|
+
|
|
183
|
+
describe('isValidLength', () => {
|
|
184
|
+
it('should return true for valid lengths', () => {
|
|
185
|
+
expect(isValidLength('hello', 1, 10)).toBe(true);
|
|
186
|
+
expect(isValidLength('a', 1, 10)).toBe(true);
|
|
187
|
+
});
|
|
188
|
+
|
|
189
|
+
it('should return false for invalid lengths', () => {
|
|
190
|
+
expect(isValidLength('', 1, 10)).toBe(false);
|
|
191
|
+
expect(isValidLength('hello world', 1, 5)).toBe(false);
|
|
192
|
+
});
|
|
193
|
+
});
|
|
194
|
+
|
|
195
|
+
describe('deepClone', () => {
|
|
196
|
+
it('should create a deep copy', () => {
|
|
197
|
+
const obj = { a: 1, b: { c: 2 } };
|
|
198
|
+
const clone = deepClone(obj);
|
|
199
|
+
|
|
200
|
+
expect(clone).toEqual(obj);
|
|
201
|
+
expect(clone).not.toBe(obj);
|
|
202
|
+
expect(clone.b).not.toBe(obj.b);
|
|
203
|
+
});
|
|
204
|
+
});
|
|
205
|
+
|
|
206
|
+
describe('isPlainObject', () => {
|
|
207
|
+
it('should return true for plain objects', () => {
|
|
208
|
+
expect(isPlainObject({})).toBe(true);
|
|
209
|
+
expect(isPlainObject({ a: 1 })).toBe(true);
|
|
210
|
+
});
|
|
211
|
+
|
|
212
|
+
it('should return false for non-plain objects', () => {
|
|
213
|
+
expect(isPlainObject([])).toBe(false);
|
|
214
|
+
expect(isPlainObject(null)).toBe(false);
|
|
215
|
+
expect(isPlainObject('string')).toBe(false);
|
|
216
|
+
expect(isPlainObject(123)).toBe(false);
|
|
217
|
+
});
|
|
218
|
+
});
|
package/tsconfig.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"compilerOptions": {
|
|
3
|
-
"target": "
|
|
4
|
-
"module": "
|
|
5
|
-
"lib": ["
|
|
3
|
+
"target": "ES2022",
|
|
4
|
+
"module": "CommonJS",
|
|
5
|
+
"lib": ["ES2022"],
|
|
6
6
|
"outDir": "./dist",
|
|
7
|
-
"rootDir": "
|
|
7
|
+
"rootDir": "./src",
|
|
8
8
|
"strict": true,
|
|
9
9
|
"esModuleInterop": true,
|
|
10
10
|
"skipLibCheck": true,
|
|
@@ -13,13 +13,18 @@
|
|
|
13
13
|
"declarationMap": true,
|
|
14
14
|
"sourceMap": true,
|
|
15
15
|
"resolveJsonModule": true,
|
|
16
|
-
"moduleResolution": "node"
|
|
16
|
+
"moduleResolution": "node",
|
|
17
|
+
"noImplicitAny": true,
|
|
18
|
+
"strictNullChecks": false,
|
|
19
|
+
"noImplicitReturns": true,
|
|
20
|
+
"noFallthroughCasesInSwitch": true,
|
|
21
|
+
"noUncheckedIndexedAccess": true,
|
|
22
|
+
"exactOptionalPropertyTypes": false,
|
|
23
|
+
"noImplicitOverride": true,
|
|
24
|
+
"noPropertyAccessFromIndexSignature": false,
|
|
25
|
+
"noUnusedLocals": false,
|
|
26
|
+
"noUnusedParameters": false
|
|
17
27
|
},
|
|
18
|
-
"include": [
|
|
19
|
-
|
|
20
|
-
],
|
|
21
|
-
"exclude": [
|
|
22
|
-
"node_modules",
|
|
23
|
-
"dist"
|
|
24
|
-
]
|
|
28
|
+
"include": ["src/**/*"],
|
|
29
|
+
"exclude": ["node_modules", "dist", "tests"]
|
|
25
30
|
}
|
package/GEMINI.md
DELETED
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
# Sequential Thinking System (gthinking)
|
|
2
|
-
|
|
3
|
-
This project is a comprehensive intelligent thinking framework designed to perform complex problem solving, research, and analysis through a sequential process. It operates as a Model Context Protocol (MCP) server, allowing AI agents to leverage its capabilities.
|
|
4
|
-
|
|
5
|
-
## Project Overview
|
|
6
|
-
|
|
7
|
-
**Type:** TypeScript / Node.js Application (MCP Server)
|
|
8
|
-
|
|
9
|
-
The system is architected as a "Modular Monolith" where a central `SequentialThinkingEngine` orchestrates various specialized modules (engines) to process queries. It simulates (or delegates to LLMs) cognitive processes like reasoning, planning, and creativity.
|
|
10
|
-
|
|
11
|
-
### Key Components
|
|
12
|
-
|
|
13
|
-
* **`server.ts`**: The entry point for the MCP server. It exposes tools like `think`, `quick_search`, and `creative_solve`.
|
|
14
|
-
* **`engine.ts`**: The main orchestrator (`SequentialThinkingEngine`) that manages the flow of data between different thinking stages.
|
|
15
|
-
* **`llm-service.ts`**: A bridge service that executes local CLI commands (`gemini`, `claude`, `kimi`, `opencode`) to perform actual cognitive tasks (Reasoning, Analysis, Creativity) using external LLMs.
|
|
16
|
-
* **Modules:**
|
|
17
|
-
* `search-discovery.ts`: Web search simulation and aggregation.
|
|
18
|
-
* `analysis.ts`: Deep content analysis (Sentiment, Entities, Fact-checking).
|
|
19
|
-
* `reasoning.ts`: Logical reasoning (Deductive, Inductive, Chain of Thought).
|
|
20
|
-
* `creativity.ts`: Idea generation (Brainstorming, SCAMPER, Six Hats).
|
|
21
|
-
* `planning.ts`: Task decomposition and project planning.
|
|
22
|
-
* `learning.ts`: Context memory and knowledge graph management.
|
|
23
|
-
|
|
24
|
-
## Building and Running
|
|
25
|
-
|
|
26
|
-
### Prerequisites
|
|
27
|
-
* Node.js (>=16.0.0)
|
|
28
|
-
* TypeScript
|
|
29
|
-
* Local LLM CLIs installed (optional but recommended: `gemini`, `claude`, etc.)
|
|
30
|
-
|
|
31
|
-
### Commands
|
|
32
|
-
|
|
33
|
-
* **Install Dependencies:**
|
|
34
|
-
```bash
|
|
35
|
-
npm install
|
|
36
|
-
```
|
|
37
|
-
|
|
38
|
-
* **Build Project:**
|
|
39
|
-
Compiles TypeScript to JavaScript in the `dist/` directory.
|
|
40
|
-
```bash
|
|
41
|
-
npm run build
|
|
42
|
-
```
|
|
43
|
-
|
|
44
|
-
* **Run Development Mode:**
|
|
45
|
-
Runs the examples using `ts-node`.
|
|
46
|
-
```bash
|
|
47
|
-
npm run dev
|
|
48
|
-
```
|
|
49
|
-
|
|
50
|
-
* **Run MCP Server:**
|
|
51
|
-
```bash
|
|
52
|
-
node dist/server.js
|
|
53
|
-
```
|
|
54
|
-
*Note: This is typically run by an MCP client (like Claude Desktop or Gemini CLI).*
|
|
55
|
-
|
|
56
|
-
## Development Conventions
|
|
57
|
-
|
|
58
|
-
* **Architecture:** Follows a strict modular design. Each "Engine" (e.g., `ReasoningEngine`) should be self-contained in its own file and export a singleton instance.
|
|
59
|
-
* **Communication:** Modules communicate via standard TypeScript interfaces defined in `types.ts`. The main `engine.ts` handles the workflow.
|
|
60
|
-
* **LLM Integration:** Do not hardcode API calls in the modules. Use `llmService` from `llm-service.ts` to delegate complex tasks to the configured local LLM provider.
|
|
61
|
-
* **Error Handling:** Use the `ThinkingError` class for typed error handling within the thinking pipeline.
|
|
62
|
-
|
|
63
|
-
## Configuration
|
|
64
|
-
|
|
65
|
-
* **LLM Provider:** The system automatically detects installed CLIs (`gemini`, `claude`). You can force a specific provider by setting the `LLM_PROVIDER` environment variable.
|
|
66
|
-
```bash
|
|
67
|
-
export LLM_PROVIDER=claude
|
|
68
|
-
```
|