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
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();
|
|
77
72
|
|
|
78
|
-
|
|
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
|
+
```
|
|
79
81
|
|
|
80
|
-
|
|
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
|
|
81
102
|
|
|
82
103
|
```json
|
|
83
104
|
{
|
|
@@ -86,241 +107,200 @@ 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`
|
|
98
|
-
|
|
99
|
-
### Gemini Instruction (Prompt)
|
|
118
|
+
## CLI Mode (No API Key Required)
|
|
100
119
|
|
|
101
|
-
|
|
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.
|
|
102
121
|
|
|
103
|
-
|
|
122
|
+
### Configuration
|
|
104
123
|
|
|
105
|
-
|
|
124
|
+
Set the `GTHINKING_LLM_PROVIDER` to `cli` and specify your command.
|
|
106
125
|
|
|
107
|
-
|
|
126
|
+
#### 1. Gemini CLI (Smart Defaults)
|
|
127
|
+
If you use the standard Gemini CLI, `gthinking` automatically configures the arguments for you.
|
|
108
128
|
|
|
109
|
-
```
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
id: 'request_1',
|
|
114
|
-
query: 'What are the implications of AI in healthcare?'
|
|
115
|
-
});
|
|
116
|
-
|
|
117
|
-
console.log(response.finalAnswer);
|
|
118
|
-
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"
|
|
119
133
|
```
|
|
120
134
|
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
```typescript
|
|
124
|
-
import { think } from 'sequential-thinking-system';
|
|
135
|
+
#### 2. Other Tools (Generic)
|
|
136
|
+
For tools that read from `stdin` (standard input):
|
|
125
137
|
|
|
126
|
-
|
|
127
|
-
|
|
138
|
+
```bash
|
|
139
|
+
export GTHINKING_LLM_PROVIDER=cli
|
|
140
|
+
export GTHINKING_LLM_CLI_COMMAND=opencode
|
|
141
|
+
# System will execute: opencode << "your prompt"
|
|
128
142
|
```
|
|
129
143
|
|
|
130
|
-
|
|
144
|
+
#### 3. Custom Arguments
|
|
145
|
+
For tools requiring specific flags or arguments:
|
|
131
146
|
|
|
132
|
-
```
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
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"
|
|
140
154
|
```
|
|
141
155
|
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
```typescript
|
|
145
|
-
import { solveCreatively } from 'sequential-thinking-system';
|
|
156
|
+
## Configuration
|
|
146
157
|
|
|
147
|
-
|
|
148
|
-
'How to reduce urban traffic congestion?'
|
|
149
|
-
);
|
|
150
|
-
console.log(solution);
|
|
151
|
-
```
|
|
158
|
+
### Environment Variables
|
|
152
159
|
|
|
153
|
-
|
|
160
|
+
```bash
|
|
161
|
+
# LLM Configuration
|
|
162
|
+
GTHINKING_LLM_PROVIDER=gemini
|
|
163
|
+
GTHINKING_LLM_API_KEY=your-api-key
|
|
164
|
+
GTHINKING_LLM_MODEL=gemini-pro
|
|
154
165
|
|
|
155
|
-
|
|
156
|
-
|
|
166
|
+
# Search Configuration
|
|
167
|
+
GTHINKING_SEARCH_API_KEY=your-search-api-key
|
|
157
168
|
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
console.log(`Estimated duration: ${plan.timeline.endDate}`);
|
|
169
|
+
# Logging
|
|
170
|
+
GTHINKING_LOG_LEVEL=info
|
|
161
171
|
```
|
|
162
172
|
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
### กำหนดค่าการทำงาน
|
|
173
|
+
### Programmatic Configuration
|
|
166
174
|
|
|
167
175
|
```typescript
|
|
168
|
-
import { SequentialThinkingEngine } from '
|
|
169
|
-
|
|
170
|
-
const
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
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
|
+
},
|
|
178
192
|
});
|
|
179
193
|
|
|
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
|
-
});
|
|
194
|
+
const engine = new SequentialThinkingEngine(config.getConfig());
|
|
191
195
|
```
|
|
192
196
|
|
|
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
|
-
});
|
|
197
|
+
## API Reference
|
|
210
198
|
|
|
211
|
-
|
|
212
|
-
const analysis = await analysisEngine.analyze(content, {
|
|
213
|
-
types: ['sentiment', 'entity', 'topic'],
|
|
214
|
-
depth: 'deep'
|
|
215
|
-
});
|
|
199
|
+
### SequentialThinkingEngine
|
|
216
200
|
|
|
217
|
-
|
|
218
|
-
const reasoning = await reasoningEngine.reason(problem, {
|
|
219
|
-
type: 'deductive',
|
|
220
|
-
maxSteps: 5
|
|
221
|
-
});
|
|
201
|
+
The main orchestrator class that coordinates all thinking stages.
|
|
222
202
|
|
|
223
|
-
|
|
224
|
-
const context = learningEngine.getOrCreateContext('session_1');
|
|
225
|
-
learningEngine.recordInteraction('session_1', query, response);
|
|
203
|
+
#### Methods
|
|
226
204
|
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
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
|
|
232
210
|
|
|
233
|
-
|
|
234
|
-
const session = creativityEngine.startSession('Improve user experience', {
|
|
235
|
-
techniques: ['brainstorming', 'scamper'],
|
|
236
|
-
ideaCount: 20
|
|
237
|
-
});
|
|
238
|
-
```
|
|
211
|
+
### Individual Engines
|
|
239
212
|
|
|
240
|
-
|
|
213
|
+
Each engine can be used independently:
|
|
241
214
|
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
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
|
|
246
222
|
|
|
247
|
-
|
|
248
|
-
console.log(`Found ${event.data.results.length} results`);
|
|
249
|
-
});
|
|
223
|
+
## Security
|
|
250
224
|
|
|
251
|
-
|
|
252
|
-
console.log(`Analysis confidence: ${event.data.confidence}`);
|
|
253
|
-
});
|
|
254
|
-
```
|
|
225
|
+
Version 2.0.0 includes significant security improvements:
|
|
255
226
|
|
|
256
|
-
|
|
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
|
|
257
231
|
|
|
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
|
-
```
|
|
232
|
+
## Performance
|
|
271
233
|
|
|
272
|
-
|
|
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
|
|
273
238
|
|
|
274
|
-
|
|
239
|
+
## Error Handling
|
|
275
240
|
|
|
276
241
|
```typescript
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
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
|
+
}
|
|
281
253
|
```
|
|
282
254
|
|
|
283
|
-
|
|
255
|
+
## Testing
|
|
284
256
|
|
|
285
|
-
```
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
{
|
|
289
|
-
resources: [developer, designer],
|
|
290
|
-
deadline: new Date('2024-06-01')
|
|
291
|
-
}
|
|
292
|
-
);
|
|
293
|
-
// ได้รับ: รายการงานย่อย ลำดับความสำคัญ ไทม์ไลน์
|
|
294
|
-
```
|
|
257
|
+
```bash
|
|
258
|
+
# Run all tests
|
|
259
|
+
npm test
|
|
295
260
|
|
|
296
|
-
|
|
261
|
+
# Run with coverage
|
|
262
|
+
npm run test:coverage
|
|
297
263
|
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
'Increase customer engagement'
|
|
301
|
-
);
|
|
302
|
-
// ได้รับ: ไอเดียใหม่ๆ มุมมองที่แตกต่าง แนวทางปฏิบัติ
|
|
264
|
+
# Run in watch mode
|
|
265
|
+
npm run test:watch
|
|
303
266
|
```
|
|
304
267
|
|
|
305
|
-
|
|
268
|
+
## Contributing
|
|
306
269
|
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
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
|
|
315
279
|
|
|
316
|
-
##
|
|
280
|
+
## Changelog
|
|
317
281
|
|
|
318
|
-
|
|
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.
|
|
319
286
|
|
|
320
|
-
|
|
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.
|
|
321
292
|
|
|
322
|
-
|
|
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
|
|
323
303
|
|
|
324
|
-
##
|
|
304
|
+
## Support
|
|
325
305
|
|
|
326
|
-
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"}
|