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,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.
|
|
4
|
-
"description": "
|
|
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
|
-
"
|
|
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": "
|
|
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/
|
|
38
|
+
"url": "https://github.com/gotza02/gthinking.git"
|
|
51
39
|
},
|
|
52
40
|
"bugs": {
|
|
53
|
-
"url": "https://github.com/
|
|
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
|
-
"
|
|
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
|
}
|