Sequential Thinking System v2.1 - Advanced multi-stage thinking engine with AI-powered analysis, reasoning, and planning. Now supports local CLI tools!
npm install gthinkingSequential Thinking System - Advanced multi-stage thinking engine with AI-powered analysis, reasoning, and planning.
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.
``bash`
npm install gthinking
`typescript
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 results
`
`typescript
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"
`
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.
Add this to your MCP settings file (e.g., in Claude Desktop or other MCP clients):
`json`
{
"mcpServers": {
"gthinking": {
"command": "npx",
"args": ["-y", "gthinking"],
"env": {
"GTHINKING_LLM_PROVIDER": "cli",
"GTHINKING_LLM_CLI_COMMAND": "gemini",
"GTHINKING_LLM_CLI_ARGS": "-p"
}
}
}
}
`bashProvider Selection
GTHINKING_LLM_PROVIDER=cli # 'cli' or 'gemini' (API)
API Reference
$3
The main orchestrator class that coordinates all thinking stages.
-
think(request: ThinkingRequest): Promise
- quickSearch(query: string): Promise (Uses Search + Analysis)
- deepAnalysis(query: string): Promise (Full Pipeline)$3
-
analyze(request: AnalysisRequest): PromiseSupported Analysis Types:
-
AnalysisType.SENTIMENT
- AnalysisType.ENTITY
- AnalysisType.TOPIC
- AnalysisType.KEYWORD
- AnalysisType.SUMMARY
- AnalysisType.READABILITYSecurity
- Input Sanitization: rigorous sanitization of all inputs to prevent injection.
- Secure Execution: CLI mode uses
spawn with non-shell execution.
- Validation: Zod schemas for runtime type checking.Contributing
1. Fork the repository
2. Create a feature branch
3. Make your changes
4. Add tests
5. Submit a pull request
License
MIT License
Changelog
$3
- Documentation: Updated README to reflect current module status.
- Maintenance: Internal package updates and stability improvements.$3
- Feature: Fully implemented AnalysisEngine.
- Security: Hardened input sanitization (sanitizeForShell).
- Integration: SequentialThinkingEngine now defaults to AnalysisEngine` for analysis tasks.