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.
- package/.eslintrc.js +34 -0
- package/ANALYSIS_SUMMARY.md +363 -0
- package/README.md +230 -245
- 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 -37
- 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 -677
- 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 -58
- package/dist/planning.d.ts.map +0 -1
- package/dist/planning.js +0 -824
- 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 -947
- 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 -1028
- 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 -42
- package/types.ts +0 -6
- /package/dist/{server.d.ts → mcp/server.d.ts} +0 -0
package/README.md
CHANGED
|
@@ -1,78 +1,104 @@
|
|
|
1
|
-
#
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
##
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
- **
|
|
14
|
-
- **
|
|
15
|
-
- **
|
|
16
|
-
- **
|
|
17
|
-
|
|
18
|
-
###
|
|
19
|
-
-
|
|
20
|
-
-
|
|
21
|
-
-
|
|
22
|
-
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
-
|
|
29
|
-
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
-
|
|
37
|
-
-
|
|
38
|
-
|
|
39
|
-
###
|
|
40
|
-
-
|
|
41
|
-
-
|
|
42
|
-
-
|
|
43
|
-
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
-
|
|
48
|
-
-
|
|
49
|
-
-
|
|
50
|
-
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
-
|
|
55
|
-
-
|
|
56
|
-
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
- **Concept Connection**: เชื่อมโยงแนวคิด
|
|
60
|
-
|
|
61
|
-
## การติดตั้ง
|
|
1
|
+
# gthinking v2.1.1
|
|
2
|
+
|
|
3
|
+
Sequential Thinking System - Advanced multi-stage thinking engine with AI-powered analysis, reasoning, and planning
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
`gthinking` is a comprehensive TypeScript library that implements a sequential thinking system designed to solve complex problems through multiple stages of analysis, reasoning, and synthesis. Version 2.1.1 brings critical security updates and a fully implemented Analysis Engine.
|
|
8
|
+
|
|
9
|
+
## Features
|
|
10
|
+
|
|
11
|
+
### Core Features
|
|
12
|
+
- **Sequential Thinking Pipeline**: 8-stage thinking process (Search → Analysis → Reasoning → Learning → Planning → Creativity → Synthesis → Evaluation)
|
|
13
|
+
- **Dynamic Pipeline**: Automatically selects appropriate stages based on query context
|
|
14
|
+
- **Parallel Execution**: Supports parallel execution of independent stages
|
|
15
|
+
- **Streaming Support**: Real-time results as each stage completes
|
|
16
|
+
- **Caching Layer**: Intelligent caching to reduce redundant processing
|
|
17
|
+
|
|
18
|
+
### Search & Discovery
|
|
19
|
+
- Multi-provider web search (Google, Bing, Brave, DuckDuckGo)
|
|
20
|
+
- Knowledge base integration
|
|
21
|
+
- Intelligent result ranking and aggregation
|
|
22
|
+
- Conflict detection and consensus scoring
|
|
23
|
+
|
|
24
|
+
### Analysis
|
|
25
|
+
- Sentiment analysis with emotion detection
|
|
26
|
+
- Entity extraction (people, organizations, locations, etc.)
|
|
27
|
+
- Topic extraction and keyword analysis
|
|
28
|
+
- Text summarization
|
|
29
|
+
- Fact checking
|
|
30
|
+
- Language detection
|
|
31
|
+
- Readability analysis
|
|
32
|
+
|
|
33
|
+
### Reasoning
|
|
34
|
+
- 6 types of reasoning: Deductive, Inductive, Abductive, Analogical, Causal, Counterfactual
|
|
35
|
+
- Chain of Thought generation
|
|
36
|
+
- Hypothesis management and testing
|
|
37
|
+
- Problem decomposition
|
|
38
|
+
|
|
39
|
+
### Planning
|
|
40
|
+
- Task decomposition and prioritization
|
|
41
|
+
- Resource allocation
|
|
42
|
+
- Timeline generation with critical path analysis
|
|
43
|
+
- Risk assessment and mitigation
|
|
44
|
+
|
|
45
|
+
### Creativity
|
|
46
|
+
- Brainstorming with multiple techniques
|
|
47
|
+
- SCAMPER analysis
|
|
48
|
+
- Six Thinking Hats
|
|
49
|
+
- Mind mapping
|
|
50
|
+
- Out-of-box thinking perspectives
|
|
51
|
+
|
|
52
|
+
### Learning
|
|
53
|
+
- Pattern recognition
|
|
54
|
+
- Knowledge graph management
|
|
55
|
+
- Context memory
|
|
56
|
+
- User preference learning
|
|
57
|
+
|
|
58
|
+
## Installation
|
|
62
59
|
|
|
63
60
|
```bash
|
|
64
|
-
npm install
|
|
61
|
+
npm install gthinking
|
|
65
62
|
```
|
|
66
63
|
|
|
67
|
-
##
|
|
64
|
+
## Quick Start
|
|
68
65
|
|
|
69
|
-
|
|
66
|
+
### Basic Usage
|
|
70
67
|
|
|
71
|
-
|
|
68
|
+
```typescript
|
|
69
|
+
import { SequentialThinkingEngine } from 'gthinking';
|
|
70
|
+
|
|
71
|
+
const engine = new SequentialThinkingEngine();
|
|
72
72
|
|
|
73
|
-
|
|
73
|
+
const result = await engine.think({
|
|
74
|
+
query: 'How can we improve remote work productivity?',
|
|
75
|
+
preferredStages: ['search', 'analysis', 'reasoning', 'synthesis'],
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
console.log(result.summary);
|
|
79
|
+
console.log(result.recommendations);
|
|
80
|
+
```
|
|
74
81
|
|
|
75
|
-
|
|
82
|
+
### Using Individual Engines
|
|
83
|
+
|
|
84
|
+
```typescript
|
|
85
|
+
import { AnalysisEngine, ReasoningEngine } from 'gthinking';
|
|
86
|
+
|
|
87
|
+
// Analysis
|
|
88
|
+
const analysis = await AnalysisEngine.analyze({
|
|
89
|
+
content: 'Your text here...',
|
|
90
|
+
types: ['sentiment', 'entity', 'keyword'],
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
// Reasoning
|
|
94
|
+
const reasoning = await ReasoningEngine.reason({
|
|
95
|
+
problem: 'Should we expand to Asian markets?',
|
|
96
|
+
type: 'deductive',
|
|
97
|
+
context: ['Current market saturation in US', 'Growing Asian economy'],
|
|
98
|
+
});
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
### MCP Server Usage
|
|
76
102
|
|
|
77
103
|
```json
|
|
78
104
|
{
|
|
@@ -81,241 +107,200 @@ npm install sequential-thinking-system
|
|
|
81
107
|
"command": "npx",
|
|
82
108
|
"args": ["-y", "gthinking"],
|
|
83
109
|
"env": {
|
|
84
|
-
"LLM_PROVIDER": "gemini"
|
|
110
|
+
"LLM_PROVIDER": "gemini",
|
|
111
|
+
"LLM_API_KEY": "your-api-key"
|
|
85
112
|
}
|
|
86
113
|
}
|
|
87
114
|
}
|
|
88
115
|
}
|
|
89
116
|
```
|
|
90
117
|
|
|
91
|
-
|
|
92
|
-
* `LLM_PROVIDER`: เลือก LLM ที่ติดตั้งในเครื่องเพื่อใช้ประมวลผล (รองรับ: `gemini`, `claude`, `kimi`, `opencode`) - ค่าเริ่มต้นคือ `gemini`
|
|
93
|
-
|
|
94
|
-
### Gemini Instruction (Prompt)
|
|
118
|
+
## CLI Mode (No API Key Required)
|
|
95
119
|
|
|
96
|
-
|
|
120
|
+
`gthinking` v2.1.0 introduces **CLI Mode**, allowing you to use local CLI tools (like Gemini CLI, Claude CLI, or custom wrappers) directly without requiring an API key in the configuration. This is ideal for users who are already authenticated via OAuth in their terminal.
|
|
97
121
|
|
|
98
|
-
|
|
122
|
+
### Configuration
|
|
99
123
|
|
|
100
|
-
|
|
124
|
+
Set the `GTHINKING_LLM_PROVIDER` to `cli` and specify your command.
|
|
101
125
|
|
|
102
|
-
|
|
126
|
+
#### 1. Gemini CLI (Smart Defaults)
|
|
127
|
+
If you use the standard Gemini CLI, `gthinking` automatically configures the arguments for you.
|
|
103
128
|
|
|
104
|
-
```
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
id: 'request_1',
|
|
109
|
-
query: 'What are the implications of AI in healthcare?'
|
|
110
|
-
});
|
|
111
|
-
|
|
112
|
-
console.log(response.finalAnswer);
|
|
113
|
-
console.log(`Confidence: ${response.confidence}`);
|
|
129
|
+
```bash
|
|
130
|
+
export GTHINKING_LLM_PROVIDER=cli
|
|
131
|
+
export GTHINKING_LLM_CLI_COMMAND=gemini
|
|
132
|
+
# System will execute: gemini -p "your prompt"
|
|
114
133
|
```
|
|
115
134
|
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
```typescript
|
|
119
|
-
import { think } from 'sequential-thinking-system';
|
|
135
|
+
#### 2. Other Tools (Generic)
|
|
136
|
+
For tools that read from `stdin` (standard input):
|
|
120
137
|
|
|
121
|
-
|
|
122
|
-
|
|
138
|
+
```bash
|
|
139
|
+
export GTHINKING_LLM_PROVIDER=cli
|
|
140
|
+
export GTHINKING_LLM_CLI_COMMAND=opencode
|
|
141
|
+
# System will execute: opencode << "your prompt"
|
|
123
142
|
```
|
|
124
143
|
|
|
125
|
-
|
|
144
|
+
#### 3. Custom Arguments
|
|
145
|
+
For tools requiring specific flags or arguments:
|
|
126
146
|
|
|
127
|
-
```
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
console.log(analysis);
|
|
147
|
+
```bash
|
|
148
|
+
export GTHINKING_LLM_PROVIDER=cli
|
|
149
|
+
export GTHINKING_LLM_CLI_COMMAND=mytool
|
|
150
|
+
export GTHINKING_LLM_CLI_ARGS="--fast,--json"
|
|
151
|
+
export GTHINKING_LLM_CLI_PROMPT_METHOD=arg
|
|
152
|
+
export GTHINKING_LLM_CLI_PROMPT_FLAG=--query
|
|
153
|
+
# System will execute: mytool --fast --json --query "your prompt"
|
|
135
154
|
```
|
|
136
155
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
```typescript
|
|
140
|
-
import { solveCreatively } from 'sequential-thinking-system';
|
|
156
|
+
## Configuration
|
|
141
157
|
|
|
142
|
-
|
|
143
|
-
'How to reduce urban traffic congestion?'
|
|
144
|
-
);
|
|
145
|
-
console.log(solution);
|
|
146
|
-
```
|
|
158
|
+
### Environment Variables
|
|
147
159
|
|
|
148
|
-
|
|
160
|
+
```bash
|
|
161
|
+
# LLM Configuration
|
|
162
|
+
GTHINKING_LLM_PROVIDER=gemini
|
|
163
|
+
GTHINKING_LLM_API_KEY=your-api-key
|
|
164
|
+
GTHINKING_LLM_MODEL=gemini-pro
|
|
149
165
|
|
|
150
|
-
|
|
151
|
-
|
|
166
|
+
# Search Configuration
|
|
167
|
+
GTHINKING_SEARCH_API_KEY=your-search-api-key
|
|
152
168
|
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
console.log(`Estimated duration: ${plan.timeline.endDate}`);
|
|
169
|
+
# Logging
|
|
170
|
+
GTHINKING_LOG_LEVEL=info
|
|
156
171
|
```
|
|
157
172
|
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
### กำหนดค่าการทำงาน
|
|
173
|
+
### Programmatic Configuration
|
|
161
174
|
|
|
162
175
|
```typescript
|
|
163
|
-
import { SequentialThinkingEngine } from '
|
|
164
|
-
|
|
165
|
-
const
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
176
|
+
import { SequentialThinkingEngine, ConfigManager } from 'gthinking';
|
|
177
|
+
|
|
178
|
+
const config = new ConfigManager({
|
|
179
|
+
llm: {
|
|
180
|
+
provider: 'openai',
|
|
181
|
+
apiKey: 'your-api-key',
|
|
182
|
+
model: 'gpt-4',
|
|
183
|
+
},
|
|
184
|
+
search: {
|
|
185
|
+
providers: ['google', 'bing'],
|
|
186
|
+
maxResults: 20,
|
|
187
|
+
},
|
|
188
|
+
cache: {
|
|
189
|
+
enabled: true,
|
|
190
|
+
maxSize: 2000,
|
|
191
|
+
},
|
|
173
192
|
});
|
|
174
193
|
|
|
175
|
-
const
|
|
176
|
-
id: 'advanced_request',
|
|
177
|
-
query: 'Complex problem to solve',
|
|
178
|
-
preferredStages: [
|
|
179
|
-
'search',
|
|
180
|
-
'analysis',
|
|
181
|
-
'reasoning',
|
|
182
|
-
'creativity',
|
|
183
|
-
'synthesis'
|
|
184
|
-
]
|
|
185
|
-
});
|
|
194
|
+
const engine = new SequentialThinkingEngine(config.getConfig());
|
|
186
195
|
```
|
|
187
196
|
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
```typescript
|
|
191
|
-
import {
|
|
192
|
-
searchEngine,
|
|
193
|
-
analysisEngine,
|
|
194
|
-
reasoningEngine,
|
|
195
|
-
learningEngine,
|
|
196
|
-
planningEngine,
|
|
197
|
-
creativityEngine
|
|
198
|
-
} from 'sequential-thinking-system';
|
|
199
|
-
|
|
200
|
-
// Search
|
|
201
|
-
const searchResults = await searchEngine.search('AI ethics', {
|
|
202
|
-
maxResults: 10,
|
|
203
|
-
sources: ['web', 'knowledge_base']
|
|
204
|
-
});
|
|
197
|
+
## API Reference
|
|
205
198
|
|
|
206
|
-
|
|
207
|
-
const analysis = await analysisEngine.analyze(content, {
|
|
208
|
-
types: ['sentiment', 'entity', 'topic'],
|
|
209
|
-
depth: 'deep'
|
|
210
|
-
});
|
|
199
|
+
### SequentialThinkingEngine
|
|
211
200
|
|
|
212
|
-
|
|
213
|
-
const reasoning = await reasoningEngine.reason(problem, {
|
|
214
|
-
type: 'deductive',
|
|
215
|
-
maxSteps: 5
|
|
216
|
-
});
|
|
201
|
+
The main orchestrator class that coordinates all thinking stages.
|
|
217
202
|
|
|
218
|
-
|
|
219
|
-
const context = learningEngine.getOrCreateContext('session_1');
|
|
220
|
-
learningEngine.recordInteraction('session_1', query, response);
|
|
203
|
+
#### Methods
|
|
221
204
|
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
205
|
+
- `think(request: ThinkingRequest): Promise<SynthesisResult>` - Execute full thinking pipeline
|
|
206
|
+
- `quickSearch(query: string): Promise<SynthesisResult>` - Fast search with minimal stages
|
|
207
|
+
- `deepAnalysis(query: string): Promise<SynthesisResult>` - Comprehensive analysis with all stages
|
|
208
|
+
- `creativeSolve(challenge: string): Promise<CreativeResult>` - Creative problem solving
|
|
209
|
+
- `createPlan(goal: string, options?: PlanningOptions): Promise<Plan>` - Generate execution plan
|
|
227
210
|
|
|
228
|
-
|
|
229
|
-
const session = creativityEngine.startSession('Improve user experience', {
|
|
230
|
-
techniques: ['brainstorming', 'scamper'],
|
|
231
|
-
ideaCount: 20
|
|
232
|
-
});
|
|
233
|
-
```
|
|
211
|
+
### Individual Engines
|
|
234
212
|
|
|
235
|
-
|
|
213
|
+
Each engine can be used independently:
|
|
236
214
|
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
215
|
+
- `SearchDiscoveryEngine` - Web search and knowledge retrieval
|
|
216
|
+
- `AnalysisEngine` - Content analysis
|
|
217
|
+
- `ReasoningEngine` - Logical reasoning
|
|
218
|
+
- `PlanningEngine` - Task planning
|
|
219
|
+
- `CreativityEngine` - Creative thinking
|
|
220
|
+
- `LearningEngine` - Pattern learning
|
|
221
|
+
- `SynthesisEngine` - Result synthesis
|
|
241
222
|
|
|
242
|
-
|
|
243
|
-
console.log(`Found ${event.data.results.length} results`);
|
|
244
|
-
});
|
|
223
|
+
## Security
|
|
245
224
|
|
|
246
|
-
|
|
247
|
-
console.log(`Analysis confidence: ${event.data.confidence}`);
|
|
248
|
-
});
|
|
249
|
-
```
|
|
225
|
+
Version 2.0.0 includes significant security improvements:
|
|
250
226
|
|
|
251
|
-
|
|
227
|
+
- **Input Sanitization**: All user inputs are sanitized to prevent injection attacks
|
|
228
|
+
- **Rate Limiting**: Built-in rate limiting to prevent abuse
|
|
229
|
+
- **Safe LLM Calls**: HTTP API calls instead of shell commands
|
|
230
|
+
- **Validation**: Comprehensive input validation using Zod schemas
|
|
252
231
|
|
|
253
|
-
|
|
254
|
-
sequential-thinking-system/
|
|
255
|
-
├── types.ts # Type definitions
|
|
256
|
-
├── search-discovery.ts # Search module
|
|
257
|
-
├── analysis.ts # Analysis module
|
|
258
|
-
├── reasoning.ts # Reasoning module
|
|
259
|
-
├── learning.ts # Learning module
|
|
260
|
-
├── planning.ts # Planning module
|
|
261
|
-
├── creativity.ts # Creativity module
|
|
262
|
-
├── engine.ts # Main engine
|
|
263
|
-
├── index.ts # Exports
|
|
264
|
-
└── README.md # Documentation
|
|
265
|
-
```
|
|
232
|
+
## Performance
|
|
266
233
|
|
|
267
|
-
|
|
234
|
+
- **Caching**: Multi-level caching with TTL support
|
|
235
|
+
- **Parallel Execution**: Independent stages run in parallel
|
|
236
|
+
- **Streaming**: Real-time results without waiting for all stages
|
|
237
|
+
- **Metrics**: Built-in performance metrics collection
|
|
268
238
|
|
|
269
|
-
|
|
239
|
+
## Error Handling
|
|
270
240
|
|
|
271
241
|
```typescript
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
242
|
+
import { ThinkingError, TimeoutError, ValidationError } from 'gthinking';
|
|
243
|
+
|
|
244
|
+
try {
|
|
245
|
+
const result = await engine.think({ query: '...' });
|
|
246
|
+
} catch (error) {
|
|
247
|
+
if (error instanceof TimeoutError) {
|
|
248
|
+
console.log('Operation timed out:', error.stage);
|
|
249
|
+
} else if (error instanceof ValidationError) {
|
|
250
|
+
console.log('Validation failed:', error.details);
|
|
251
|
+
}
|
|
252
|
+
}
|
|
276
253
|
```
|
|
277
254
|
|
|
278
|
-
|
|
255
|
+
## Testing
|
|
279
256
|
|
|
280
|
-
```
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
{
|
|
284
|
-
resources: [developer, designer],
|
|
285
|
-
deadline: new Date('2024-06-01')
|
|
286
|
-
}
|
|
287
|
-
);
|
|
288
|
-
// ได้รับ: รายการงานย่อย ลำดับความสำคัญ ไทม์ไลน์
|
|
289
|
-
```
|
|
257
|
+
```bash
|
|
258
|
+
# Run all tests
|
|
259
|
+
npm test
|
|
290
260
|
|
|
291
|
-
|
|
261
|
+
# Run with coverage
|
|
262
|
+
npm run test:coverage
|
|
292
263
|
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
'Increase customer engagement'
|
|
296
|
-
);
|
|
297
|
-
// ได้รับ: ไอเดียใหม่ๆ มุมมองที่แตกต่าง แนวทางปฏิบัติ
|
|
264
|
+
# Run in watch mode
|
|
265
|
+
npm run test:watch
|
|
298
266
|
```
|
|
299
267
|
|
|
300
|
-
|
|
268
|
+
## Contributing
|
|
301
269
|
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
270
|
+
1. Fork the repository
|
|
271
|
+
2. Create a feature branch
|
|
272
|
+
3. Make your changes
|
|
273
|
+
4. Add tests
|
|
274
|
+
5. Submit a pull request
|
|
275
|
+
|
|
276
|
+
## License
|
|
277
|
+
|
|
278
|
+
MIT License - see LICENSE file for details
|
|
310
279
|
|
|
311
|
-
##
|
|
280
|
+
## Changelog
|
|
312
281
|
|
|
313
|
-
|
|
282
|
+
### v2.1.1
|
|
283
|
+
- **Security Update**: Hardened input sanitization (`sanitizeForShell`) to strictly allow only alphanumeric and safe characters, preventing potential command injection.
|
|
284
|
+
- **New Feature**: Fully implemented `AnalysisEngine` with support for Sentiment Analysis, Entity Extraction, Topic Extraction, Keyword Extraction, Summarization, and Readability metrics.
|
|
285
|
+
- **Integration**: `SequentialThinkingEngine` now automatically initializes and uses `AnalysisEngine` for analysis tasks.
|
|
314
286
|
|
|
315
|
-
|
|
287
|
+
### v2.1.0
|
|
288
|
+
- **New Feature**: CLI Provider support! Connect `gthinking` to any local LLM CLI tool (Gemini, Claude, etc.).
|
|
289
|
+
- Added `CLIProvider` for secure local process execution.
|
|
290
|
+
- Added support for custom CLI arguments and prompt passing methods (Stdin/Arg).
|
|
291
|
+
- Smart defaults for Gemini CLI integration.
|
|
316
292
|
|
|
317
|
-
|
|
293
|
+
### v2.0.0
|
|
294
|
+
- Complete rewrite with improved architecture
|
|
295
|
+
- Added security features (input sanitization, rate limiting)
|
|
296
|
+
- Implemented caching layer
|
|
297
|
+
- Added streaming support
|
|
298
|
+
- Improved error handling
|
|
299
|
+
- Added comprehensive test suite
|
|
300
|
+
- Enhanced type safety
|
|
301
|
+
- Added metrics collection
|
|
302
|
+
- Improved LLM integration with HTTP APIs
|
|
318
303
|
|
|
319
|
-
##
|
|
304
|
+
## Support
|
|
320
305
|
|
|
321
|
-
For
|
|
306
|
+
For issues and feature requests, please use the [GitHub issue tracker](https://github.com/gotza02/gthinking/issues).
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Analysis Engine for gthinking v2.0.0
|
|
3
|
+
* AI-powered content analysis including sentiment, entities, topics, and more.
|
|
4
|
+
*/
|
|
5
|
+
import { EventEmitter } from 'events';
|
|
6
|
+
import { LLMService } from '../llm/llm-service';
|
|
7
|
+
import { CompleteAnalysisResult } from '../types';
|
|
8
|
+
/**
|
|
9
|
+
* Analysis Engine
|
|
10
|
+
*/
|
|
11
|
+
export declare class AnalysisEngine extends EventEmitter {
|
|
12
|
+
private llmService;
|
|
13
|
+
constructor(llmService?: LLMService);
|
|
14
|
+
/**
|
|
15
|
+
* Set the LLM service
|
|
16
|
+
* @param llmService - The LLM service instance
|
|
17
|
+
*/
|
|
18
|
+
setLLMService(llmService: LLMService): void;
|
|
19
|
+
/**
|
|
20
|
+
* Analyze content based on request
|
|
21
|
+
* @param request - The analysis request
|
|
22
|
+
* @returns Complete analysis result
|
|
23
|
+
*/
|
|
24
|
+
analyze(request: unknown): Promise<CompleteAnalysisResult>;
|
|
25
|
+
/**
|
|
26
|
+
* Analyze sentiment
|
|
27
|
+
*/
|
|
28
|
+
private analyzeSentiment;
|
|
29
|
+
/**
|
|
30
|
+
* Extract entities
|
|
31
|
+
*/
|
|
32
|
+
private extractEntities;
|
|
33
|
+
/**
|
|
34
|
+
* Extract topics
|
|
35
|
+
*/
|
|
36
|
+
private extractTopics;
|
|
37
|
+
/**
|
|
38
|
+
* Extract keywords
|
|
39
|
+
*/
|
|
40
|
+
private extractKeywords;
|
|
41
|
+
/**
|
|
42
|
+
* Generate summary
|
|
43
|
+
*/
|
|
44
|
+
private generateSummary;
|
|
45
|
+
/**
|
|
46
|
+
* Calculate readability metrics (Locally)
|
|
47
|
+
*/
|
|
48
|
+
private analyzeReadability;
|
|
49
|
+
private countSyllables;
|
|
50
|
+
private countComplexWords;
|
|
51
|
+
private getGradeLevel;
|
|
52
|
+
/**
|
|
53
|
+
* Execute LLM analysis with retries and parsing
|
|
54
|
+
*/
|
|
55
|
+
private executeLLMAnalysis;
|
|
56
|
+
private ensureLLM;
|
|
57
|
+
private calculateOverallConfidence;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Factory function
|
|
61
|
+
*/
|
|
62
|
+
export declare function createAnalysisEngine(llmService?: LLMService): AnalysisEngine;
|
|
63
|
+
//# sourceMappingURL=analysis-engine.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"analysis-engine.d.ts","sourceRoot":"","sources":["../../src/analysis/analysis-engine.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAEtC,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAIL,sBAAsB,EASvB,MAAM,UAAU,CAAC;AAMlB;;GAEG;AACH,qBAAa,cAAe,SAAQ,YAAY;IAC9C,OAAO,CAAC,UAAU,CAA2B;gBAEjC,UAAU,CAAC,EAAE,UAAU;IAKnC;;;OAGG;IACI,aAAa,CAAC,UAAU,EAAE,UAAU,GAAG,IAAI;IAIlD;;;;OAIG;IACU,OAAO,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,sBAAsB,CAAC;IA4EvE;;OAEG;YACW,gBAAgB;IAiB9B;;OAEG;YACW,eAAe;IAmC7B;;OAEG;YACW,aAAa;IA+B3B;;OAEG;YACW,eAAe;IAgC7B;;OAEG;YACW,eAAe;IA0B7B;;OAEG;IACH,OAAO,CAAC,kBAAkB;IAmC1B,OAAO,CAAC,cAAc;IAKtB,OAAO,CAAC,iBAAiB;IAKzB,OAAO,CAAC,aAAa;IAQrB;;OAEG;YACW,kBAAkB;IAiBhC,OAAO,CAAC,SAAS;IAMjB,OAAO,CAAC,0BAA0B;CAUnC;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,UAAU,CAAC,EAAE,UAAU,GAAG,cAAc,CAE5E"}
|