gthinking 1.3.0 → 2.1.2
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 +248 -246
- 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 +323 -0
- package/dist/analysis/analysis-engine.js.map +1 -0
- package/dist/core/config.d.ts +1423 -0
- package/dist/core/config.d.ts.map +1 -0
- package/dist/core/config.js +445 -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 +384 -0
- package/src/core/config.ts +462 -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
package/README.md
CHANGED
|
@@ -1,83 +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
|
-
- **Brainstorming**: ระดมความคิด
|
|
60
|
-
- **SCAMPER Technique**: เทคนิค SCAMPER
|
|
61
|
-
- **Six Thinking Hats**: หมวก 6 ใบ
|
|
62
|
-
- **Mind Mapping**: แผนที่ความคิด
|
|
63
|
-
- **Out-of-Box Thinking**: คิดนอกกรอบ
|
|
64
|
-
- **Concept Connection**: เชื่อมโยงแนวคิด
|
|
65
|
-
|
|
66
|
-
## การติดตั้ง
|
|
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
|
|
67
59
|
|
|
68
60
|
```bash
|
|
69
|
-
npm install
|
|
61
|
+
npm install gthinking
|
|
70
62
|
```
|
|
71
63
|
|
|
72
|
-
##
|
|
64
|
+
## Quick Start
|
|
73
65
|
|
|
74
|
-
|
|
66
|
+
### Basic Usage
|
|
75
67
|
|
|
76
|
-
|
|
68
|
+
```typescript
|
|
69
|
+
import { SequentialThinkingEngine } from 'gthinking';
|
|
70
|
+
|
|
71
|
+
const engine = new SequentialThinkingEngine();
|
|
72
|
+
|
|
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
|
+
```
|
|
81
|
+
|
|
82
|
+
### Using Individual Engines
|
|
83
|
+
|
|
84
|
+
```typescript
|
|
85
|
+
import { AnalysisEngine, ReasoningEngine } from 'gthinking';
|
|
77
86
|
|
|
78
|
-
|
|
87
|
+
// Analysis
|
|
88
|
+
const analysis = await AnalysisEngine.analyze({
|
|
89
|
+
content: 'Your text here...',
|
|
90
|
+
types: ['sentiment', 'entity', 'keyword'],
|
|
91
|
+
});
|
|
79
92
|
|
|
80
|
-
|
|
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
|
|
81
102
|
|
|
82
103
|
```json
|
|
83
104
|
{
|
|
@@ -86,241 +107,222 @@ npm install sequential-thinking-system
|
|
|
86
107
|
"command": "npx",
|
|
87
108
|
"args": ["-y", "gthinking"],
|
|
88
109
|
"env": {
|
|
89
|
-
"LLM_PROVIDER": "gemini"
|
|
110
|
+
"LLM_PROVIDER": "gemini",
|
|
111
|
+
"LLM_API_KEY": "your-api-key"
|
|
90
112
|
}
|
|
91
113
|
}
|
|
92
114
|
}
|
|
93
115
|
}
|
|
94
116
|
```
|
|
95
117
|
|
|
96
|
-
|
|
97
|
-
* `LLM_PROVIDER`: เลือก LLM ที่ติดตั้งในเครื่องเพื่อใช้ประมวลผล (รองรับ: `gemini`, `claude`, `kimi`, `opencode`) - ค่าเริ่มต้นคือ `gemini`
|
|
118
|
+
## CLI Mode (No API Key Required)
|
|
98
119
|
|
|
99
|
-
|
|
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.
|
|
100
121
|
|
|
101
|
-
|
|
122
|
+
### Configuration
|
|
102
123
|
|
|
103
|
-
|
|
124
|
+
Set the `GTHINKING_LLM_PROVIDER` to `cli` and specify your command.
|
|
104
125
|
|
|
105
|
-
|
|
126
|
+
#### 1. Gemini CLI (Smart Defaults)
|
|
127
|
+
If you use the standard Gemini CLI, `gthinking` automatically configures the arguments for you.
|
|
106
128
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
129
|
+
```bash
|
|
130
|
+
export GTHINKING_LLM_PROVIDER=cli
|
|
131
|
+
export GTHINKING_LLM_CLI_COMMAND=gemini
|
|
132
|
+
# System will execute: gemini -p "your prompt"
|
|
133
|
+
```
|
|
111
134
|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
query: 'What are the implications of AI in healthcare?'
|
|
115
|
-
});
|
|
135
|
+
#### 2. Other Tools (Generic)
|
|
136
|
+
For tools that read from `stdin` (standard input):
|
|
116
137
|
|
|
117
|
-
|
|
118
|
-
|
|
138
|
+
```bash
|
|
139
|
+
export GTHINKING_LLM_PROVIDER=cli
|
|
140
|
+
export GTHINKING_LLM_CLI_COMMAND=opencode
|
|
141
|
+
# System will execute: opencode << "your prompt"
|
|
119
142
|
```
|
|
120
143
|
|
|
121
|
-
|
|
144
|
+
#### 3. Custom Arguments
|
|
145
|
+
For tools requiring specific flags or arguments:
|
|
122
146
|
|
|
123
|
-
```
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
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"
|
|
128
154
|
```
|
|
129
155
|
|
|
130
|
-
|
|
156
|
+
## Configuration File (Optional)
|
|
131
157
|
|
|
132
|
-
|
|
133
|
-
|
|
158
|
+
`gthinking` supports loading configuration from a JSON file located at `~/.gemini/settings.json`. This is useful for persisting configuration across sessions without relying solely on environment variables.
|
|
159
|
+
|
|
160
|
+
The file structure mimics the MCP settings format:
|
|
134
161
|
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
162
|
+
```json
|
|
163
|
+
{
|
|
164
|
+
"mcpServers": {
|
|
165
|
+
"gthinking": {
|
|
166
|
+
"env": {
|
|
167
|
+
"GTHINKING_LLM_PROVIDER": "gemini",
|
|
168
|
+
"GTHINKING_LLM_API_KEY": "your-api-key",
|
|
169
|
+
"GTHINKING_LLM_CLI_COMMAND": "gemini"
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
}
|
|
140
174
|
```
|
|
141
175
|
|
|
142
|
-
|
|
176
|
+
Environment variables will always override settings loaded from this file.
|
|
143
177
|
|
|
144
|
-
|
|
145
|
-
import { solveCreatively } from 'sequential-thinking-system';
|
|
178
|
+
## Configuration
|
|
146
179
|
|
|
147
|
-
|
|
148
|
-
'How to reduce urban traffic congestion?'
|
|
149
|
-
);
|
|
150
|
-
console.log(solution);
|
|
151
|
-
```
|
|
180
|
+
### Environment Variables
|
|
152
181
|
|
|
153
|
-
|
|
182
|
+
```bash
|
|
183
|
+
# LLM Configuration
|
|
184
|
+
GTHINKING_LLM_PROVIDER=gemini
|
|
185
|
+
GTHINKING_LLM_API_KEY=your-api-key
|
|
186
|
+
GTHINKING_LLM_MODEL=gemini-pro
|
|
154
187
|
|
|
155
|
-
|
|
156
|
-
|
|
188
|
+
# Search Configuration
|
|
189
|
+
GTHINKING_SEARCH_API_KEY=your-search-api-key
|
|
157
190
|
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
console.log(`Estimated duration: ${plan.timeline.endDate}`);
|
|
191
|
+
# Logging
|
|
192
|
+
GTHINKING_LOG_LEVEL=info
|
|
161
193
|
```
|
|
162
194
|
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
### กำหนดค่าการทำงาน
|
|
195
|
+
### Programmatic Configuration
|
|
166
196
|
|
|
167
197
|
```typescript
|
|
168
|
-
import { SequentialThinkingEngine } from '
|
|
169
|
-
|
|
170
|
-
const
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
198
|
+
import { SequentialThinkingEngine, ConfigManager } from 'gthinking';
|
|
199
|
+
|
|
200
|
+
const config = new ConfigManager({
|
|
201
|
+
llm: {
|
|
202
|
+
provider: 'openai',
|
|
203
|
+
apiKey: 'your-api-key',
|
|
204
|
+
model: 'gpt-4',
|
|
205
|
+
},
|
|
206
|
+
search: {
|
|
207
|
+
providers: ['google', 'bing'],
|
|
208
|
+
maxResults: 20,
|
|
209
|
+
},
|
|
210
|
+
cache: {
|
|
211
|
+
enabled: true,
|
|
212
|
+
maxSize: 2000,
|
|
213
|
+
},
|
|
178
214
|
});
|
|
179
215
|
|
|
180
|
-
const
|
|
181
|
-
id: 'advanced_request',
|
|
182
|
-
query: 'Complex problem to solve',
|
|
183
|
-
preferredStages: [
|
|
184
|
-
'search',
|
|
185
|
-
'analysis',
|
|
186
|
-
'reasoning',
|
|
187
|
-
'creativity',
|
|
188
|
-
'synthesis'
|
|
189
|
-
]
|
|
190
|
-
});
|
|
216
|
+
const engine = new SequentialThinkingEngine(config.getConfig());
|
|
191
217
|
```
|
|
192
218
|
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
```typescript
|
|
196
|
-
import {
|
|
197
|
-
searchEngine,
|
|
198
|
-
analysisEngine,
|
|
199
|
-
reasoningEngine,
|
|
200
|
-
learningEngine,
|
|
201
|
-
planningEngine,
|
|
202
|
-
creativityEngine
|
|
203
|
-
} from 'sequential-thinking-system';
|
|
204
|
-
|
|
205
|
-
// Search
|
|
206
|
-
const searchResults = await searchEngine.search('AI ethics', {
|
|
207
|
-
maxResults: 10,
|
|
208
|
-
sources: ['web', 'knowledge_base']
|
|
209
|
-
});
|
|
219
|
+
## API Reference
|
|
210
220
|
|
|
211
|
-
|
|
212
|
-
const analysis = await analysisEngine.analyze(content, {
|
|
213
|
-
types: ['sentiment', 'entity', 'topic'],
|
|
214
|
-
depth: 'deep'
|
|
215
|
-
});
|
|
221
|
+
### SequentialThinkingEngine
|
|
216
222
|
|
|
217
|
-
|
|
218
|
-
const reasoning = await reasoningEngine.reason(problem, {
|
|
219
|
-
type: 'deductive',
|
|
220
|
-
maxSteps: 5
|
|
221
|
-
});
|
|
223
|
+
The main orchestrator class that coordinates all thinking stages.
|
|
222
224
|
|
|
223
|
-
|
|
224
|
-
const context = learningEngine.getOrCreateContext('session_1');
|
|
225
|
-
learningEngine.recordInteraction('session_1', query, response);
|
|
225
|
+
#### Methods
|
|
226
226
|
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
227
|
+
- `think(request: ThinkingRequest): Promise<SynthesisResult>` - Execute full thinking pipeline
|
|
228
|
+
- `quickSearch(query: string): Promise<SynthesisResult>` - Fast search with minimal stages
|
|
229
|
+
- `deepAnalysis(query: string): Promise<SynthesisResult>` - Comprehensive analysis with all stages
|
|
230
|
+
- `creativeSolve(challenge: string): Promise<CreativeResult>` - Creative problem solving
|
|
231
|
+
- `createPlan(goal: string, options?: PlanningOptions): Promise<Plan>` - Generate execution plan
|
|
232
232
|
|
|
233
|
-
|
|
234
|
-
const session = creativityEngine.startSession('Improve user experience', {
|
|
235
|
-
techniques: ['brainstorming', 'scamper'],
|
|
236
|
-
ideaCount: 20
|
|
237
|
-
});
|
|
238
|
-
```
|
|
233
|
+
### Individual Engines
|
|
239
234
|
|
|
240
|
-
|
|
235
|
+
Each engine can be used independently:
|
|
241
236
|
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
237
|
+
- `SearchDiscoveryEngine` - Web search and knowledge retrieval
|
|
238
|
+
- `AnalysisEngine` - Content analysis
|
|
239
|
+
- `ReasoningEngine` - Logical reasoning
|
|
240
|
+
- `PlanningEngine` - Task planning
|
|
241
|
+
- `CreativityEngine` - Creative thinking
|
|
242
|
+
- `LearningEngine` - Pattern learning
|
|
243
|
+
- `SynthesisEngine` - Result synthesis
|
|
246
244
|
|
|
247
|
-
|
|
248
|
-
console.log(`Found ${event.data.results.length} results`);
|
|
249
|
-
});
|
|
245
|
+
## Security
|
|
250
246
|
|
|
251
|
-
|
|
252
|
-
console.log(`Analysis confidence: ${event.data.confidence}`);
|
|
253
|
-
});
|
|
254
|
-
```
|
|
247
|
+
Version 2.0.0 includes significant security improvements:
|
|
255
248
|
|
|
256
|
-
|
|
249
|
+
- **Input Sanitization**: All user inputs are sanitized to prevent injection attacks
|
|
250
|
+
- **Rate Limiting**: Built-in rate limiting to prevent abuse
|
|
251
|
+
- **Safe LLM Calls**: HTTP API calls instead of shell commands
|
|
252
|
+
- **Validation**: Comprehensive input validation using Zod schemas
|
|
257
253
|
|
|
258
|
-
|
|
259
|
-
sequential-thinking-system/
|
|
260
|
-
├── types.ts # Type definitions
|
|
261
|
-
├── search-discovery.ts # Search module
|
|
262
|
-
├── analysis.ts # Analysis module
|
|
263
|
-
├── reasoning.ts # Reasoning module
|
|
264
|
-
├── learning.ts # Learning module
|
|
265
|
-
├── planning.ts # Planning module
|
|
266
|
-
├── creativity.ts # Creativity module
|
|
267
|
-
├── engine.ts # Main engine
|
|
268
|
-
├── index.ts # Exports
|
|
269
|
-
└── README.md # Documentation
|
|
270
|
-
```
|
|
254
|
+
## Performance
|
|
271
255
|
|
|
272
|
-
|
|
256
|
+
- **Caching**: Multi-level caching with TTL support
|
|
257
|
+
- **Parallel Execution**: Independent stages run in parallel
|
|
258
|
+
- **Streaming**: Real-time results without waiting for all stages
|
|
259
|
+
- **Metrics**: Built-in performance metrics collection
|
|
273
260
|
|
|
274
|
-
|
|
261
|
+
## Error Handling
|
|
275
262
|
|
|
276
263
|
```typescript
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
264
|
+
import { ThinkingError, TimeoutError, ValidationError } from 'gthinking';
|
|
265
|
+
|
|
266
|
+
try {
|
|
267
|
+
const result = await engine.think({ query: '...' });
|
|
268
|
+
} catch (error) {
|
|
269
|
+
if (error instanceof TimeoutError) {
|
|
270
|
+
console.log('Operation timed out:', error.stage);
|
|
271
|
+
} else if (error instanceof ValidationError) {
|
|
272
|
+
console.log('Validation failed:', error.details);
|
|
273
|
+
}
|
|
274
|
+
}
|
|
281
275
|
```
|
|
282
276
|
|
|
283
|
-
|
|
277
|
+
## Testing
|
|
284
278
|
|
|
285
|
-
```
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
{
|
|
289
|
-
resources: [developer, designer],
|
|
290
|
-
deadline: new Date('2024-06-01')
|
|
291
|
-
}
|
|
292
|
-
);
|
|
293
|
-
// ได้รับ: รายการงานย่อย ลำดับความสำคัญ ไทม์ไลน์
|
|
294
|
-
```
|
|
279
|
+
```bash
|
|
280
|
+
# Run all tests
|
|
281
|
+
npm test
|
|
295
282
|
|
|
296
|
-
|
|
283
|
+
# Run with coverage
|
|
284
|
+
npm run test:coverage
|
|
297
285
|
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
'Increase customer engagement'
|
|
301
|
-
);
|
|
302
|
-
// ได้รับ: ไอเดียใหม่ๆ มุมมองที่แตกต่าง แนวทางปฏิบัติ
|
|
286
|
+
# Run in watch mode
|
|
287
|
+
npm run test:watch
|
|
303
288
|
```
|
|
304
289
|
|
|
305
|
-
|
|
290
|
+
## Contributing
|
|
306
291
|
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
292
|
+
1. Fork the repository
|
|
293
|
+
2. Create a feature branch
|
|
294
|
+
3. Make your changes
|
|
295
|
+
4. Add tests
|
|
296
|
+
5. Submit a pull request
|
|
297
|
+
|
|
298
|
+
## License
|
|
299
|
+
|
|
300
|
+
MIT License - see LICENSE file for details
|
|
315
301
|
|
|
316
|
-
##
|
|
302
|
+
## Changelog
|
|
317
303
|
|
|
318
|
-
|
|
304
|
+
### v2.1.1
|
|
305
|
+
- **Security Update**: Hardened input sanitization (`sanitizeForShell`) to strictly allow only alphanumeric and safe characters, preventing potential command injection.
|
|
306
|
+
- **New Feature**: Fully implemented `AnalysisEngine` with support for Sentiment Analysis, Entity Extraction, Topic Extraction, Keyword Extraction, Summarization, and Readability metrics.
|
|
307
|
+
- **Integration**: `SequentialThinkingEngine` now automatically initializes and uses `AnalysisEngine` for analysis tasks.
|
|
319
308
|
|
|
320
|
-
|
|
309
|
+
### v2.1.0
|
|
310
|
+
- **New Feature**: CLI Provider support! Connect `gthinking` to any local LLM CLI tool (Gemini, Claude, etc.).
|
|
311
|
+
- Added `CLIProvider` for secure local process execution.
|
|
312
|
+
- Added support for custom CLI arguments and prompt passing methods (Stdin/Arg).
|
|
313
|
+
- Smart defaults for Gemini CLI integration.
|
|
321
314
|
|
|
322
|
-
|
|
315
|
+
### v2.0.0
|
|
316
|
+
- Complete rewrite with improved architecture
|
|
317
|
+
- Added security features (input sanitization, rate limiting)
|
|
318
|
+
- Implemented caching layer
|
|
319
|
+
- Added streaming support
|
|
320
|
+
- Improved error handling
|
|
321
|
+
- Added comprehensive test suite
|
|
322
|
+
- Enhanced type safety
|
|
323
|
+
- Added metrics collection
|
|
324
|
+
- Improved LLM integration with HTTP APIs
|
|
323
325
|
|
|
324
|
-
##
|
|
326
|
+
## Support
|
|
325
327
|
|
|
326
|
-
For
|
|
328
|
+
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;AAGtC,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"}
|