gthinking
v2.1.5
Published
Sequential Thinking System v2.1 - Advanced multi-stage thinking engine with AI-powered analysis, reasoning, and planning. Now supports local CLI tools!
Maintainers
Readme
gthinking v2.1.4
Sequential Thinking System - Advanced multi-stage thinking engine with AI-powered analysis, reasoning, and planning.
Overview
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.
Current Status (v2.1.2): The Analysis Engine is fully implemented and operational. The Core Engine architecture, MCP Server, and CLI integration are stable. Other modules (Reasoning, Planning, Creativity, Search, Learning) are currently in active development and operating in placeholder mode for architectural testing.
Features
Core Capabilities
- Sequential Thinking Pipeline: 8-stage thinking process architecture (Search → Analysis → Reasoning → Learning → Planning → Creativity → Synthesis → Evaluation)
- Dynamic Pipeline: Automatically selects appropriate stages based on query context
- Parallel Execution: Supports parallel execution of independent stages
- Streaming Support: Real-time results as each stage completes
- Caching Layer: Intelligent caching to reduce redundant processing
🟢 Analysis Engine (Active)
The Analysis Engine is fully implemented and provides deep insights into text content:
- Sentiment Analysis: Detects overall sentiment (positive, negative, neutral) and specific emotions (joy, anger, fear, etc.).
- Entity Extraction: Identifies people, organizations, locations, and other key entities.
- Topic Extraction: Discovers main topics and their relevance.
- Keyword Extraction: Identifies key terms and phrases using TF-IDF and semantic analysis.
- Text Summarization: Generates abstractive summaries and key points.
- Readability Metrics: Calculates Flesch-Kincaid grade levels and other readability statistics.
🟡 Reasoning & Planning (In Development)
These modules are currently in architectural preview.
- Reasoning: Deductive, Inductive, Abductive, Analogical, Causal, Counterfactual.
- Planning: Task decomposition, Resource allocation, Critical path analysis.
- Creativity: Brainstorming, SCAMPER, Six Thinking Hats.
- Search: Multi-provider web search aggregation.
Installation
npm install gthinkingQuick Start
Basic Usage
import { SequentialThinkingEngine } from 'gthinking';
const engine = new SequentialThinkingEngine();
// The engine will analyze the query and route it through the pipeline
const result = await engine.think({
query: 'Analyze the sentiment and key topics of the recent product reviews.',
preferredStages: ['analysis'], // Currently the most active stage
});
console.log(result.summary);
console.log(result.analysis); // Access detailed analysis resultsUsing the Analysis Engine Directly
import { AnalysisEngine } from 'gthinking';
const analysis = await AnalysisEngine.analyze({
content: 'The new feature is amazing, but the UI is a bit confusing.',
types: ['sentiment', 'entity', 'keyword', 'readability'],
});
console.log(analysis.sentiment);
// { overall: 'mixed', score: 0.2, emotions: { joy: 0.6, confusion: 0.4 } }
console.log(analysis.readability.grade);
// "high_school"CLI Mode & MCP Server
gthinking v2.1.0+ supports CLI Mode, allowing you to use local CLI tools (like Gemini CLI, Claude CLI, or custom wrappers) as your LLM provider. This eliminates the need for API keys if you are authenticated locally.
MCP Configuration
Add this to your MCP settings file (e.g., in Claude Desktop or other MCP clients):
{
"mcpServers": {
"gthinking": {
"command": "npx",
"args": ["-y", "gthinking"],
"env": {
"GTHINKING_LLM_PROVIDER": "cli",
"GTHINKING_LLM_CLI_COMMAND": "gemini",
"GTHINKING_LLM_CLI_ARGS": "-p"
}
}
}
}Environment Variables
# Provider Selection
GTHINKING_LLM_PROVIDER=cli # 'cli' or 'gemini' (API)
# CLI Configuration (if provider is 'cli')
GTHINKING_LLM_CLI_COMMAND=gemini
GTHINKING_LLM_CLI_ARGS="" # Optional args
GTHINKING_LLM_CLI_PROMPT_FLAG=-p # Flag to pass prompt with (e.g. -p "prompt")
# API Configuration (if provider is 'gemini' or others)
GTHINKING_LLM_API_KEY=your-api-key
GTHINKING_LLM_MODEL=gemini-proAPI Reference
SequentialThinkingEngine
The main orchestrator class that coordinates all thinking stages.
think(request: ThinkingRequest): Promise<SynthesisResult>quickSearch(query: string): Promise<SynthesisResult>(Uses Search + Analysis)deepAnalysis(query: string): Promise<SynthesisResult>(Full Pipeline)
AnalysisEngine
analyze(request: AnalysisRequest): Promise<CompleteAnalysisResult>
Supported Analysis Types:
AnalysisType.SENTIMENTAnalysisType.ENTITYAnalysisType.TOPICAnalysisType.KEYWORDAnalysisType.SUMMARYAnalysisType.READABILITY
Security
- Input Sanitization: rigorous sanitization of all inputs to prevent injection.
- Secure Execution: CLI mode uses
spawnwith non-shell execution. - Validation: Zod schemas for runtime type checking.
Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests
- Submit a pull request
License
MIT License
Changelog
v2.1.2
- Documentation: Updated README to reflect current module status.
- Maintenance: Internal package updates and stability improvements.
v2.1.1
- Feature: Fully implemented
AnalysisEngine. - Security: Hardened input sanitization (
sanitizeForShell). - Integration:
SequentialThinkingEnginenow defaults toAnalysisEnginefor analysis tasks.
v2.1.0
- New Feature: CLI Provider support.
- Integration: Local LLM tool integration (Gemini, etc.).
