gthinking 1.2.1 → 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.
Files changed (271) hide show
  1. package/.eslintrc.js +34 -0
  2. package/ANALYSIS_SUMMARY.md +363 -0
  3. package/README.md +230 -245
  4. package/dist/analysis/analysis-engine.d.ts +63 -0
  5. package/dist/analysis/analysis-engine.d.ts.map +1 -0
  6. package/dist/analysis/analysis-engine.js +322 -0
  7. package/dist/analysis/analysis-engine.js.map +1 -0
  8. package/dist/core/config.d.ts +1419 -0
  9. package/dist/core/config.d.ts.map +1 -0
  10. package/dist/core/config.js +361 -0
  11. package/dist/core/config.js.map +1 -0
  12. package/dist/core/engine.d.ts +176 -0
  13. package/dist/core/engine.d.ts.map +1 -0
  14. package/dist/core/engine.js +604 -0
  15. package/dist/core/engine.js.map +1 -0
  16. package/dist/core/errors.d.ts +153 -0
  17. package/dist/core/errors.d.ts.map +1 -0
  18. package/dist/core/errors.js +287 -0
  19. package/dist/core/errors.js.map +1 -0
  20. package/dist/core/index.d.ts +7 -0
  21. package/dist/core/index.d.ts.map +1 -0
  22. package/dist/{types.js → core/index.js} +8 -4
  23. package/dist/core/index.js.map +1 -0
  24. package/dist/core/pipeline.d.ts +121 -0
  25. package/dist/core/pipeline.d.ts.map +1 -0
  26. package/dist/core/pipeline.js +289 -0
  27. package/dist/core/pipeline.js.map +1 -0
  28. package/dist/core/rate-limiter.d.ts +58 -0
  29. package/dist/core/rate-limiter.d.ts.map +1 -0
  30. package/dist/core/rate-limiter.js +133 -0
  31. package/dist/core/rate-limiter.js.map +1 -0
  32. package/dist/core/session-manager.d.ts +96 -0
  33. package/dist/core/session-manager.d.ts.map +1 -0
  34. package/dist/core/session-manager.js +223 -0
  35. package/dist/core/session-manager.js.map +1 -0
  36. package/dist/creativity/creativity-engine.d.ts +6 -0
  37. package/dist/creativity/creativity-engine.d.ts.map +1 -0
  38. package/dist/creativity/creativity-engine.js +17 -0
  39. package/dist/creativity/creativity-engine.js.map +1 -0
  40. package/dist/index.d.ts +24 -32
  41. package/dist/index.d.ts.map +1 -1
  42. package/dist/index.js +130 -104
  43. package/dist/index.js.map +1 -1
  44. package/dist/learning/learning-engine.d.ts +6 -0
  45. package/dist/learning/learning-engine.d.ts.map +1 -0
  46. package/dist/learning/learning-engine.js +17 -0
  47. package/dist/learning/learning-engine.js.map +1 -0
  48. package/dist/llm/index.d.ts +10 -0
  49. package/dist/llm/index.d.ts.map +1 -0
  50. package/dist/llm/index.js +26 -0
  51. package/dist/llm/index.js.map +1 -0
  52. package/dist/llm/llm-service.d.ts +109 -0
  53. package/dist/llm/llm-service.d.ts.map +1 -0
  54. package/dist/llm/llm-service.js +224 -0
  55. package/dist/llm/llm-service.js.map +1 -0
  56. package/dist/llm/providers/base.d.ts +85 -0
  57. package/dist/llm/providers/base.d.ts.map +1 -0
  58. package/dist/llm/providers/base.js +57 -0
  59. package/dist/llm/providers/base.js.map +1 -0
  60. package/dist/llm/providers/cli.d.ts +23 -0
  61. package/dist/llm/providers/cli.d.ts.map +1 -0
  62. package/dist/llm/providers/cli.js +158 -0
  63. package/dist/llm/providers/cli.js.map +1 -0
  64. package/dist/llm/providers/gemini.d.ts +30 -0
  65. package/dist/llm/providers/gemini.d.ts.map +1 -0
  66. package/dist/llm/providers/gemini.js +168 -0
  67. package/dist/llm/providers/gemini.js.map +1 -0
  68. package/dist/llm/sanitization.d.ts +50 -0
  69. package/dist/llm/sanitization.d.ts.map +1 -0
  70. package/dist/llm/sanitization.js +149 -0
  71. package/dist/llm/sanitization.js.map +1 -0
  72. package/dist/{server.d.ts.map → mcp/server.d.ts.map} +1 -1
  73. package/dist/mcp/server.js +108 -0
  74. package/dist/mcp/server.js.map +1 -0
  75. package/dist/planning/planning-engine.d.ts +6 -0
  76. package/dist/planning/planning-engine.d.ts.map +1 -0
  77. package/dist/planning/planning-engine.js +17 -0
  78. package/dist/planning/planning-engine.js.map +1 -0
  79. package/dist/reasoning/reasoning-engine.d.ts +6 -0
  80. package/dist/reasoning/reasoning-engine.d.ts.map +1 -0
  81. package/dist/reasoning/reasoning-engine.js +17 -0
  82. package/dist/reasoning/reasoning-engine.js.map +1 -0
  83. package/dist/search/search-engine.d.ts +99 -0
  84. package/dist/search/search-engine.d.ts.map +1 -0
  85. package/dist/search/search-engine.js +271 -0
  86. package/dist/search/search-engine.js.map +1 -0
  87. package/dist/synthesis/synthesis-engine.d.ts +6 -0
  88. package/dist/synthesis/synthesis-engine.d.ts.map +1 -0
  89. package/dist/synthesis/synthesis-engine.js +17 -0
  90. package/dist/synthesis/synthesis-engine.js.map +1 -0
  91. package/dist/types/analysis.d.ts +1534 -49
  92. package/dist/types/analysis.d.ts.map +1 -1
  93. package/dist/types/analysis.js +250 -0
  94. package/dist/types/analysis.js.map +1 -1
  95. package/dist/types/core.d.ts +257 -30
  96. package/dist/types/core.d.ts.map +1 -1
  97. package/dist/types/core.js +148 -18
  98. package/dist/types/core.js.map +1 -1
  99. package/dist/types/creativity.d.ts +2871 -56
  100. package/dist/types/creativity.d.ts.map +1 -1
  101. package/dist/types/creativity.js +195 -0
  102. package/dist/types/creativity.js.map +1 -1
  103. package/dist/types/index.d.ts +6 -2
  104. package/dist/types/index.d.ts.map +1 -1
  105. package/dist/types/index.js +17 -2
  106. package/dist/types/index.js.map +1 -1
  107. package/dist/types/learning.d.ts +851 -61
  108. package/dist/types/learning.d.ts.map +1 -1
  109. package/dist/types/learning.js +155 -0
  110. package/dist/types/learning.js.map +1 -1
  111. package/dist/types/planning.d.ts +2223 -71
  112. package/dist/types/planning.d.ts.map +1 -1
  113. package/dist/types/planning.js +190 -0
  114. package/dist/types/planning.js.map +1 -1
  115. package/dist/types/reasoning.d.ts +2209 -72
  116. package/dist/types/reasoning.d.ts.map +1 -1
  117. package/dist/types/reasoning.js +200 -1
  118. package/dist/types/reasoning.js.map +1 -1
  119. package/dist/types/search.d.ts +981 -53
  120. package/dist/types/search.d.ts.map +1 -1
  121. package/dist/types/search.js +137 -0
  122. package/dist/types/search.js.map +1 -1
  123. package/dist/types/synthesis.d.ts +583 -37
  124. package/dist/types/synthesis.d.ts.map +1 -1
  125. package/dist/types/synthesis.js +138 -0
  126. package/dist/types/synthesis.js.map +1 -1
  127. package/dist/utils/cache.d.ts +144 -0
  128. package/dist/utils/cache.d.ts.map +1 -0
  129. package/dist/utils/cache.js +288 -0
  130. package/dist/utils/cache.js.map +1 -0
  131. package/dist/utils/id-generator.d.ts +89 -0
  132. package/dist/utils/id-generator.d.ts.map +1 -0
  133. package/dist/utils/id-generator.js +132 -0
  134. package/dist/utils/id-generator.js.map +1 -0
  135. package/dist/utils/index.d.ts +11 -0
  136. package/dist/utils/index.d.ts.map +1 -0
  137. package/dist/utils/index.js +33 -0
  138. package/dist/utils/index.js.map +1 -0
  139. package/dist/utils/logger.d.ts +142 -0
  140. package/dist/utils/logger.d.ts.map +1 -0
  141. package/dist/utils/logger.js +248 -0
  142. package/dist/utils/logger.js.map +1 -0
  143. package/dist/utils/metrics.d.ts +149 -0
  144. package/dist/utils/metrics.d.ts.map +1 -0
  145. package/dist/utils/metrics.js +296 -0
  146. package/dist/utils/metrics.js.map +1 -0
  147. package/dist/utils/timer.d.ts +7 -0
  148. package/dist/utils/timer.d.ts.map +1 -0
  149. package/dist/utils/timer.js +17 -0
  150. package/dist/utils/timer.js.map +1 -0
  151. package/dist/utils/validation.d.ts +147 -0
  152. package/dist/utils/validation.d.ts.map +1 -0
  153. package/dist/utils/validation.js +275 -0
  154. package/dist/utils/validation.js.map +1 -0
  155. package/docs/API.md +411 -0
  156. package/docs/ARCHITECTURE.md +271 -0
  157. package/docs/CHANGELOG.md +283 -0
  158. package/jest.config.js +28 -0
  159. package/package.json +43 -30
  160. package/src/analysis/analysis-engine.ts +383 -0
  161. package/src/core/config.ts +406 -0
  162. package/src/core/engine.ts +785 -0
  163. package/src/core/errors.ts +349 -0
  164. package/src/core/index.ts +12 -0
  165. package/src/core/pipeline.ts +424 -0
  166. package/src/core/rate-limiter.ts +155 -0
  167. package/src/core/session-manager.ts +269 -0
  168. package/src/creativity/creativity-engine.ts +14 -0
  169. package/src/index.ts +178 -0
  170. package/src/learning/learning-engine.ts +14 -0
  171. package/src/llm/index.ts +10 -0
  172. package/src/llm/llm-service.ts +285 -0
  173. package/src/llm/providers/base.ts +146 -0
  174. package/src/llm/providers/cli.ts +186 -0
  175. package/src/llm/providers/gemini.ts +201 -0
  176. package/src/llm/sanitization.ts +178 -0
  177. package/src/mcp/server.ts +117 -0
  178. package/src/planning/planning-engine.ts +14 -0
  179. package/src/reasoning/reasoning-engine.ts +14 -0
  180. package/src/search/search-engine.ts +333 -0
  181. package/src/synthesis/synthesis-engine.ts +14 -0
  182. package/src/types/analysis.ts +337 -0
  183. package/src/types/core.ts +342 -0
  184. package/src/types/creativity.ts +268 -0
  185. package/src/types/index.ts +31 -0
  186. package/src/types/learning.ts +215 -0
  187. package/src/types/planning.ts +251 -0
  188. package/src/types/reasoning.ts +288 -0
  189. package/src/types/search.ts +192 -0
  190. package/src/types/synthesis.ts +187 -0
  191. package/src/utils/cache.ts +363 -0
  192. package/src/utils/id-generator.ts +135 -0
  193. package/src/utils/index.ts +22 -0
  194. package/src/utils/logger.ts +290 -0
  195. package/src/utils/metrics.ts +380 -0
  196. package/src/utils/timer.ts +15 -0
  197. package/src/utils/validation.ts +297 -0
  198. package/tests/setup.ts +22 -0
  199. package/tests/unit/cache.test.ts +189 -0
  200. package/tests/unit/engine.test.ts +179 -0
  201. package/tests/unit/validation.test.ts +218 -0
  202. package/tsconfig.json +17 -12
  203. package/GEMINI.md +0 -68
  204. package/analysis.ts +0 -1063
  205. package/creativity.ts +0 -1055
  206. package/dist/analysis.d.ts +0 -54
  207. package/dist/analysis.d.ts.map +0 -1
  208. package/dist/analysis.js +0 -866
  209. package/dist/analysis.js.map +0 -1
  210. package/dist/creativity.d.ts +0 -81
  211. package/dist/creativity.d.ts.map +0 -1
  212. package/dist/creativity.js +0 -828
  213. package/dist/creativity.js.map +0 -1
  214. package/dist/engine.d.ts +0 -90
  215. package/dist/engine.d.ts.map +0 -1
  216. package/dist/engine.js +0 -677
  217. package/dist/engine.js.map +0 -1
  218. package/dist/examples.d.ts +0 -7
  219. package/dist/examples.d.ts.map +0 -1
  220. package/dist/examples.js +0 -506
  221. package/dist/examples.js.map +0 -1
  222. package/dist/learning.d.ts +0 -72
  223. package/dist/learning.d.ts.map +0 -1
  224. package/dist/learning.js +0 -615
  225. package/dist/learning.js.map +0 -1
  226. package/dist/llm-service.d.ts +0 -21
  227. package/dist/llm-service.d.ts.map +0 -1
  228. package/dist/llm-service.js +0 -100
  229. package/dist/llm-service.js.map +0 -1
  230. package/dist/planning.d.ts +0 -58
  231. package/dist/planning.d.ts.map +0 -1
  232. package/dist/planning.js +0 -824
  233. package/dist/planning.js.map +0 -1
  234. package/dist/reasoning.d.ts +0 -73
  235. package/dist/reasoning.d.ts.map +0 -1
  236. package/dist/reasoning.js +0 -845
  237. package/dist/reasoning.js.map +0 -1
  238. package/dist/search-discovery.d.ts +0 -73
  239. package/dist/search-discovery.d.ts.map +0 -1
  240. package/dist/search-discovery.js +0 -548
  241. package/dist/search-discovery.js.map +0 -1
  242. package/dist/server.js +0 -113
  243. package/dist/server.js.map +0 -1
  244. package/dist/types/engine.d.ts +0 -55
  245. package/dist/types/engine.d.ts.map +0 -1
  246. package/dist/types/engine.js +0 -3
  247. package/dist/types/engine.js.map +0 -1
  248. package/dist/types.d.ts +0 -6
  249. package/dist/types.d.ts.map +0 -1
  250. package/dist/types.js.map +0 -1
  251. package/engine.ts +0 -947
  252. package/examples.ts +0 -717
  253. package/index.ts +0 -106
  254. package/learning.ts +0 -779
  255. package/llm-service.ts +0 -120
  256. package/planning.ts +0 -1028
  257. package/reasoning.ts +0 -1079
  258. package/search-discovery.ts +0 -700
  259. package/server.ts +0 -115
  260. package/types/analysis.ts +0 -69
  261. package/types/core.ts +0 -90
  262. package/types/creativity.ts +0 -72
  263. package/types/engine.ts +0 -60
  264. package/types/index.ts +0 -9
  265. package/types/learning.ts +0 -69
  266. package/types/planning.ts +0 -85
  267. package/types/reasoning.ts +0 -92
  268. package/types/search.ts +0 -58
  269. package/types/synthesis.ts +0 -42
  270. package/types.ts +0 -6
  271. /package/dist/{server.d.ts → mcp/server.d.ts} +0 -0
@@ -0,0 +1,271 @@
1
+ # gthinking v2.0.0 Architecture
2
+
3
+ ## Overview
4
+
5
+ The gthinking library is built on a modular, event-driven architecture that enables flexible and extensible sequential thinking workflows.
6
+
7
+ ## System Architecture
8
+
9
+ ```
10
+ ┌─────────────────────────────────────────────────────────────────┐
11
+ │ SequentialThinkingEngine │
12
+ │ (Orchestrator) │
13
+ └─────────────────────────────────────────────────────────────────┘
14
+
15
+ ┌─────────────────────┼─────────────────────┐
16
+ │ │ │
17
+ ▼ ▼ ▼
18
+ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐
19
+ │ Config │ │ Cache │ │ Sessions │
20
+ │ Manager │ │ Manager │ │ Manager │
21
+ └──────────────┘ └──────────────┘ └──────────────┘
22
+
23
+ ┌─────────────────────┼─────────────────────┐
24
+ │ │ │
25
+ ▼ ▼ ▼
26
+ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐
27
+ │ Search & │ │ Analysis │ │ Reasoning │
28
+ │ Discovery │ │ Engine │ │ Engine │
29
+ └──────────────┘ └──────────────┘ └──────────────┘
30
+ │ │ │
31
+ └─────────────────────┼─────────────────────┘
32
+
33
+ ┌─────────────────────┼─────────────────────┐
34
+ │ │ │
35
+ ▼ ▼ ▼
36
+ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐
37
+ │ Learning │ │ Planning │ │ Creativity │
38
+ │ Engine │ │ Engine │ │ Engine │
39
+ └──────────────┘ └──────────────┘ └──────────────┘
40
+
41
+
42
+ ┌──────────────┐
43
+ │ Synthesis │
44
+ │ Engine │
45
+ └──────────────┘
46
+ ```
47
+
48
+ ## Component Details
49
+
50
+ ### SequentialThinkingEngine
51
+
52
+ The main orchestrator that coordinates all thinking stages:
53
+ - **Responsibilities**:
54
+ - Request validation
55
+ - Stage selection (dynamic or explicit)
56
+ - Pipeline execution
57
+ - Result synthesis
58
+ - Session management
59
+ - Event emission
60
+
61
+ ### Stage Engines
62
+
63
+ Each stage is implemented as a separate engine:
64
+
65
+ #### 1. SearchDiscoveryEngine
66
+ - Web search via multiple providers
67
+ - Knowledge base queries
68
+ - Result aggregation and ranking
69
+
70
+ #### 2. AnalysisEngine
71
+ - Sentiment analysis
72
+ - Entity extraction
73
+ - Topic modeling
74
+ - Keyword extraction
75
+ - Text summarization
76
+ - Fact checking
77
+
78
+ #### 3. ReasoningEngine
79
+ - Deductive reasoning
80
+ - Inductive reasoning
81
+ - Abductive reasoning
82
+ - Analogical reasoning
83
+ - Causal reasoning
84
+ - Counterfactual reasoning
85
+
86
+ #### 4. LearningEngine
87
+ - Pattern recognition
88
+ - Knowledge graph management
89
+ - Context memory
90
+ - User preference learning
91
+
92
+ #### 5. PlanningEngine
93
+ - Task decomposition
94
+ - Prioritization
95
+ - Resource allocation
96
+ - Timeline generation
97
+ - Risk analysis
98
+
99
+ #### 6. CreativityEngine
100
+ - Brainstorming
101
+ - SCAMPER technique
102
+ - Six Thinking Hats
103
+ - Mind mapping
104
+ - Out-of-box thinking
105
+
106
+ #### 7. SynthesisEngine
107
+ - Result aggregation
108
+ - Devil's advocate
109
+ - Confidence calculation
110
+ - Recommendation generation
111
+
112
+ ## Data Flow
113
+
114
+ ```
115
+ 1. User Request
116
+
117
+ 2. Request Validation (Zod Schema)
118
+
119
+ 3. Cache Check
120
+
121
+ 4. Stage Selection (Dynamic or Explicit)
122
+
123
+ 5. Stage Execution
124
+ ├─ Parallel Stages
125
+ └─ Sequential Stages
126
+
127
+ 6. Result Synthesis
128
+
129
+ 7. Cache Store
130
+
131
+ 8. Return Result
132
+ ```
133
+
134
+ ## Design Patterns
135
+
136
+ ### 1. Strategy Pattern
137
+ Each reasoning type is implemented as a strategy:
138
+ ```typescript
139
+ interface ReasoningStrategy {
140
+ execute(session: ReasoningSession): Promise<void>;
141
+ }
142
+
143
+ class DeductiveStrategy implements ReasoningStrategy { ... }
144
+ class InductiveStrategy implements ReasoningStrategy { ... }
145
+ ```
146
+
147
+ ### 2. Observer Pattern
148
+ Event-driven architecture for monitoring:
149
+ ```typescript
150
+ engine.on('thinking:stage:complete', (payload) => {
151
+ console.log(`Stage ${payload.stage} completed`);
152
+ });
153
+ ```
154
+
155
+ ### 3. Factory Pattern
156
+ Engine creation via factory methods:
157
+ ```typescript
158
+ const engine = createEngine(config);
159
+ ```
160
+
161
+ ### 4. Singleton Pattern
162
+ Shared instances for managers:
163
+ ```typescript
164
+ export const cacheManager = new CacheManager();
165
+ export const configManager = new ConfigManager();
166
+ ```
167
+
168
+ ### 5. Plugin Pattern
169
+ Extensible architecture for custom functionality:
170
+ ```typescript
171
+ interface ThinkingPlugin {
172
+ name: string;
173
+ install(engine: SequentialThinkingEngine): void;
174
+ }
175
+ ```
176
+
177
+ ## Security Architecture
178
+
179
+ ### Input Sanitization
180
+ - All user inputs sanitized before processing
181
+ - Zod schema validation
182
+ - Shell command injection prevention
183
+
184
+ ### Rate Limiting
185
+ - Per-session rate limiting
186
+ - Configurable limits
187
+ - Automatic throttling
188
+
189
+ ### Error Handling
190
+ - Structured error types
191
+ - Safe error messages (no sensitive info)
192
+ - Retry mechanisms
193
+
194
+ ## Performance Architecture
195
+
196
+ ### Caching Strategy
197
+ - Multi-level caching
198
+ - TTL-based expiration
199
+ - LRU eviction
200
+ - Cache warming
201
+
202
+ ### Parallel Execution
203
+ - Independent stages run in parallel
204
+ - Configurable concurrency
205
+ - Resource pooling
206
+
207
+ ### Streaming Support
208
+ - Real-time result streaming
209
+ - Progressive rendering
210
+ - Backpressure handling
211
+
212
+ ## Extensibility
213
+
214
+ ### Plugin System
215
+ ```typescript
216
+ class MyPlugin implements ThinkingPlugin {
217
+ name = 'my-plugin';
218
+
219
+ install(engine: SequentialThinkingEngine): void {
220
+ engine.on('thinking:complete', this.onComplete.bind(this));
221
+ }
222
+ }
223
+
224
+ engine.use(new MyPlugin());
225
+ ```
226
+
227
+ ### Custom Stages
228
+ ```typescript
229
+ engine.registerStage('custom', new CustomStageExecutor());
230
+ ```
231
+
232
+ ### Custom Providers
233
+ ```typescript
234
+ engine.registerLLMProvider('custom', new CustomLLMProvider());
235
+ engine.registerSearchProvider('custom', new CustomSearchProvider());
236
+ ```
237
+
238
+ ## Testing Architecture
239
+
240
+ ### Unit Tests
241
+ - Individual engine tests
242
+ - Utility function tests
243
+ - Type validation tests
244
+
245
+ ### Integration Tests
246
+ - Full pipeline tests
247
+ - Multi-engine interaction tests
248
+ - End-to-end tests
249
+
250
+ ### Mock Implementations
251
+ - Mock LLM providers
252
+ - Mock search providers
253
+ - Mock cache implementations
254
+
255
+ ## Deployment Architecture
256
+
257
+ ### NPM Package
258
+ - TypeScript source
259
+ - Compiled JavaScript
260
+ - Type definitions
261
+ - Source maps
262
+
263
+ ### MCP Server
264
+ - Standalone executable
265
+ - Environment configuration
266
+ - Stdio transport
267
+
268
+ ### Docker Support
269
+ - Containerized deployment
270
+ - Environment variable configuration
271
+ - Volume mounting for persistence
@@ -0,0 +1,283 @@
1
+ # Changelog
2
+
3
+ All notable changes to the gthinking project will be documented in this file.
4
+
5
+ ## [2.1.0] - 2024-02-01
6
+
7
+ ### New Features
8
+
9
+ #### LLM Integration
10
+ - **CLI Provider**: Added support for using local CLI tools as LLM providers (`provider: 'cli'`).
11
+ - **No API Key Mode**: Ability to run without API keys by leveraging local CLI authentication (OAuth).
12
+ - **Flexible Configuration**:
13
+ - `cliCommand`: Specify any executable command.
14
+ - `cliArgs`: Pass custom arguments to the CLI tool.
15
+ - `promptPassingMethod`: Choose between `stdin` (streaming safe) or `arg` (flag based).
16
+ - `promptFlag`: Customize the prompt flag (e.g., `-p`, `--query`).
17
+ - **Smart Defaults**: Auto-configuration for common tools like `gemini` (automatically sets `-p` flag).
18
+
19
+ ### Security
20
+ - **Secure Spawn**: Implemented `spawn` with non-shell execution to prevent command injection in CLI mode.
21
+ - **Stream Handling**: Improved stream backpressure management to prevent memory leaks in CLI mode.
22
+
23
+ ## [2.0.0] - 2024-01-01
24
+
25
+ ### Major Changes
26
+
27
+ #### Security
28
+ - **BREAKING**: Replaced shell command execution with HTTP API calls for LLM providers
29
+ - Added comprehensive input sanitization to prevent injection attacks
30
+ - Implemented rate limiting to prevent abuse
31
+ - Added security configuration options
32
+ - Removed all command-line tool dependencies
33
+
34
+ #### Architecture
35
+ - Complete rewrite with modular architecture
36
+ - Implemented plugin system for extensibility
37
+ - Added support for parallel stage execution
38
+ - Implemented streaming response support
39
+ - Added event-driven architecture with EventEmitter
40
+
41
+ #### Performance
42
+ - Implemented multi-level caching with TTL support
43
+ - Added cache warming and preloading
44
+ - Implemented LRU eviction strategy
45
+ - Added parallel execution for independent stages
46
+ - Implemented streaming for real-time results
47
+
48
+ #### Error Handling
49
+ - Added structured error types (GThinkingError, ValidationError, TimeoutError, etc.)
50
+ - Implemented retry mechanisms with exponential backoff
51
+ - Added error recovery strategies
52
+ - Implemented error event emission
53
+ - Added comprehensive error logging
54
+
55
+ #### Type Safety
56
+ - Migrated to strict TypeScript mode
57
+ - Added comprehensive Zod schemas for all inputs
58
+ - Removed all `any` types
59
+ - Added strict null checks
60
+ - Implemented comprehensive type definitions
61
+
62
+ #### Testing
63
+ - Added Jest testing framework
64
+ - Implemented unit tests for all modules
65
+ - Added integration tests
66
+ - Set up code coverage reporting (80%+ target)
67
+ - Added test utilities and mocks
68
+
69
+ #### Configuration
70
+ - Added centralized configuration management
71
+ - Implemented environment variable loading
72
+ - Added configuration validation
73
+ - Added support for custom validators
74
+ - Implemented configuration merging
75
+
76
+ #### Logging
77
+ - Implemented Winston logging framework
78
+ - Added structured logging support
79
+ - Implemented log levels (debug, info, warn, error)
80
+ - Added file and console transport options
81
+ - Implemented performance logging
82
+
83
+ #### Metrics
84
+ - Added metrics collection system
85
+ - Implemented counter, gauge, histogram, and timer metrics
86
+ - Added Prometheus export format
87
+ - Implemented performance tracking decorators
88
+ - Added operation tracking utilities
89
+
90
+ #### Cache
91
+ - Implemented in-memory cache with TTL
92
+ - Added LRU eviction strategy
93
+ - Implemented cache statistics
94
+ - Added cache persistence options
95
+ - Implemented memoization decorator
96
+
97
+ ### New Features
98
+
99
+ #### Core Engine
100
+ - Dynamic pipeline selection based on query analysis
101
+ - Session management with cleanup
102
+ - Cache key generation
103
+ - Stage dependency management
104
+ - Result synthesis
105
+
106
+ #### Search & Discovery
107
+ - Multi-provider search support (Google, Bing, Brave, DuckDuckGo)
108
+ - Result aggregation and ranking
109
+ - Conflict detection
110
+ - Consensus scoring
111
+ - Knowledge base integration
112
+
113
+ #### Analysis
114
+ - Sentiment analysis with emotion detection
115
+ - Entity extraction (people, organizations, locations, etc.)
116
+ - Topic extraction
117
+ - Keyword extraction with TF-IDF
118
+ - Text summarization (extractive and abstractive)
119
+ - Fact checking
120
+ - Language detection
121
+ - Readability analysis
122
+
123
+ #### Reasoning
124
+ - 6 types of reasoning (deductive, inductive, abductive, analogical, causal, counterfactual)
125
+ - Chain of Thought generation
126
+ - Hypothesis management
127
+ - Problem decomposition
128
+ - Logical rule engine
129
+
130
+ #### Planning
131
+ - Task decomposition
132
+ - Prioritization with multiple criteria
133
+ - Resource allocation
134
+ - Timeline generation with critical path
135
+ - Risk analysis
136
+
137
+ #### Creativity
138
+ - Brainstorming with multiple techniques
139
+ - SCAMPER analysis
140
+ - Six Thinking Hats
141
+ - Mind mapping
142
+ - Out-of-box thinking perspectives
143
+ - Concept connection
144
+
145
+ #### Learning
146
+ - Pattern recognition
147
+ - Knowledge graph management
148
+ - Context memory
149
+ - User preference learning
150
+ - Interaction recording
151
+
152
+ #### Synthesis
153
+ - Result aggregation
154
+ - Devil's advocate mode
155
+ - Confidence calculation
156
+ - Recommendation generation
157
+ - Output formatting
158
+
159
+ ### Improvements
160
+
161
+ #### Code Quality
162
+ - Added ESLint configuration
163
+ - Implemented strict TypeScript rules
164
+ - Added JSDoc documentation
165
+ - Implemented code formatting
166
+ - Added pre-commit hooks
167
+
168
+ #### Documentation
169
+ - Added comprehensive README
170
+ - Added architecture documentation
171
+ - Added API reference
172
+ - Added usage examples
173
+ - Added troubleshooting guide
174
+
175
+ #### Developer Experience
176
+ - Added TypeScript declaration maps
177
+ - Implemented source maps
178
+ - Added hot reload for development
179
+ - Implemented debug logging
180
+ - Added development utilities
181
+
182
+ ### Bug Fixes
183
+
184
+ #### Security
185
+ - Fixed command injection vulnerability in LLM service
186
+ - Fixed input validation bypass
187
+ - Fixed regex ReDoS vulnerabilities
188
+ - Fixed unsafe JSON parsing
189
+
190
+ #### Stability
191
+ - Fixed memory leaks in session management
192
+ - Fixed event listener leaks
193
+ - Fixed cache cleanup issues
194
+ - Fixed timeout handling
195
+
196
+ #### Performance
197
+ - Fixed blocking operations
198
+ - Fixed unnecessary re-renders
199
+ - Fixed cache thrashing
200
+ - Fixed memory bloat
201
+
202
+ ### Removed
203
+
204
+ #### Deprecated Features
205
+ - Removed shell command execution
206
+ - Removed exec/spawn usage
207
+ - Removed hardcoded API keys
208
+ - Removed insecure random number generation
209
+
210
+ #### Unused Code
211
+ - Removed commented code
212
+ - Removed unused imports
213
+ - Removed dead code paths
214
+ - Removed unused dependencies
215
+
216
+ ### Dependencies
217
+
218
+ #### Added
219
+ - `uuid` - UUID generation
220
+ - `winston` - Logging framework
221
+ - `axios` - HTTP client
222
+ - `jest` - Testing framework
223
+ - `@types/jest` - Jest type definitions
224
+ - `ts-jest` - TypeScript Jest preprocessor
225
+ - `@typescript-eslint/*` - TypeScript ESLint plugins
226
+
227
+ #### Updated
228
+ - `typescript` to 5.3.3
229
+ - `zod` to 3.22.4
230
+ - `@modelcontextprotocol/sdk` to 1.25.3
231
+
232
+ #### Removed
233
+ - `exec` and `spawn` dependencies
234
+ - Unused utility libraries
235
+ - Deprecated type definitions
236
+
237
+ ## [1.3.0] - 2023-12-15
238
+
239
+ ### Added
240
+ - Dynamic Pipeline feature
241
+ - Devil's Advocate Mode
242
+ - Dynamic Planning in PlanningEngine
243
+
244
+ ### Security
245
+ - Fixed Command Injection Vulnerability (changed from exec to spawn)
246
+
247
+ ### Refactoring
248
+ - Split large types.ts into modules
249
+ - Added Dependency Injection support
250
+
251
+ ## [1.2.1] - 2023-12-10
252
+
253
+ ### Security
254
+ - Security fix for command injection
255
+
256
+ ### Architecture
257
+ - Added Dependency Injection in SequentialThinkingEngine
258
+
259
+ ## [1.2.0] - 2023-12-05
260
+
261
+ ### Added
262
+ - New reasoning types
263
+ - Enhanced creativity techniques
264
+ - Improved learning algorithms
265
+
266
+ ## [1.1.0] - 2023-11-20
267
+
268
+ ### Added
269
+ - MCP server support
270
+ - Additional search providers
271
+ - Enhanced analysis features
272
+
273
+ ## [1.0.0] - 2023-11-01
274
+
275
+ ### Initial Release
276
+ - Basic sequential thinking pipeline
277
+ - Search and discovery
278
+ - Analysis engine
279
+ - Reasoning engine
280
+ - Planning engine
281
+ - Creativity engine
282
+ - Learning engine
283
+ - Synthesis engine
package/jest.config.js ADDED
@@ -0,0 +1,28 @@
1
+ module.exports = {
2
+ preset: 'ts-jest',
3
+ testEnvironment: 'node',
4
+ roots: ['<rootDir>/tests'],
5
+ testMatch: ['**/*.test.ts'],
6
+ transform: {
7
+ '^.+\\.ts$': 'ts-jest',
8
+ },
9
+ collectCoverageFrom: [
10
+ 'src/**/*.ts',
11
+ '!src/**/*.d.ts',
12
+ '!src/examples.ts',
13
+ ],
14
+ coverageThreshold: {
15
+ global: {
16
+ branches: 20,
17
+ functions: 20,
18
+ lines: 20,
19
+ statements: 20,
20
+ },
21
+ },
22
+ coverageDirectory: 'coverage',
23
+ coverageReporters: ['text', 'lcov', 'html'],
24
+ moduleNameMapper: {
25
+ '^@/(.*)$': '<rootDir>/src/$1',
26
+ },
27
+ setupFilesAfterEnv: ['<rootDir>/tests/setup.ts'],
28
+ };
package/package.json CHANGED
@@ -1,18 +1,21 @@
1
1
  {
2
2
  "name": "gthinking",
3
- "version": "1.2.1",
4
- "description": "A comprehensive intelligent sequential thinking framework for complex problem solving",
3
+ "version": "2.1.1",
4
+ "description": "Sequential Thinking System v2.1 - Advanced multi-stage thinking engine with AI-powered analysis, reasoning, and planning. Now supports local CLI tools!",
5
5
  "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
6
7
  "bin": {
7
- "gthinking": "dist/server.js"
8
+ "gthinking": "dist/mcp/server.js"
8
9
  },
9
- "types": "dist/index.d.ts",
10
10
  "scripts": {
11
- "build": "tsc && chmod +x dist/server.js",
12
- "dev": "ts-node examples.ts",
13
- "test": "jest",
11
+ "build": "tsc && chmod +x dist/mcp/server.js",
12
+ "dev": "ts-node src/examples.ts",
13
+ "test": "jest --coverage",
14
+ "test:watch": "jest --watch",
14
15
  "lint": "eslint . --ext .ts",
15
- "clean": "rm -rf dist"
16
+ "lint:fix": "eslint . --ext .ts --fix",
17
+ "clean": "rm -rf dist coverage",
18
+ "prepublishOnly": "npm run clean && npm run build && npm test"
16
19
  },
17
20
  "keywords": [
18
21
  "ai",
@@ -24,33 +27,43 @@
24
27
  "learning",
25
28
  "search",
26
29
  "nlp",
27
- "decision-making"
30
+ "decision-making",
31
+ "mcp",
32
+ "sequential-thinking"
28
33
  ],
29
- "author": "Sequential Thinking Team",
34
+ "author": "Gotza02",
30
35
  "license": "MIT",
31
- "dependencies": {
32
- "@modelcontextprotocol/sdk": "^1.25.3",
33
- "events": "^3.3.0",
34
- "zod": "^4.3.6"
35
- },
36
- "devDependencies": {
37
- "@types/node": "^20.0.0",
38
- "@typescript-eslint/eslint-plugin": "^6.0.0",
39
- "@typescript-eslint/parser": "^6.0.0",
40
- "eslint": "^8.0.0",
41
- "jest": "^29.0.0",
42
- "ts-node": "^10.9.0",
43
- "typescript": "^5.0.0"
44
- },
45
- "engines": {
46
- "node": ">=16.0.0"
47
- },
48
36
  "repository": {
49
37
  "type": "git",
50
- "url": "https://github.com/your-org/sequential-thinking-system.git"
38
+ "url": "https://github.com/gotza02/gthinking.git"
51
39
  },
52
40
  "bugs": {
53
- "url": "https://github.com/your-org/sequential-thinking-system/issues"
41
+ "url": "https://github.com/gotza02/gthinking/issues"
42
+ },
43
+ "homepage": "https://github.com/gotza02/gthinking#readme",
44
+ "engines": {
45
+ "node": ">=18.0.0"
46
+ },
47
+ "dependencies": {
48
+ "@modelcontextprotocol/sdk": "^1.25.3",
49
+ "axios": "^1.6.5",
50
+ "eventemitter3": "^5.0.4",
51
+ "events": "^3.3.0",
52
+ "rate-limiter-flexible": "^9.0.1",
53
+ "uuid": "^9.0.1",
54
+ "winston": "^3.11.0",
55
+ "zod": "^3.22.4"
54
56
  },
55
- "homepage": "https://github.com/your-org/sequential-thinking-system#readme"
57
+ "devDependencies": {
58
+ "@types/jest": "^29.5.11",
59
+ "@types/node": "^20.10.6",
60
+ "@types/uuid": "^9.0.7",
61
+ "@typescript-eslint/eslint-plugin": "^6.17.0",
62
+ "@typescript-eslint/parser": "^6.17.0",
63
+ "eslint": "^8.56.0",
64
+ "jest": "^29.7.0",
65
+ "ts-jest": "^29.1.1",
66
+ "ts-node": "^10.9.2",
67
+ "typescript": "^5.3.3"
68
+ }
56
69
  }