@gotza02/sequential-thinking 2026.2.2 → 2026.2.3

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/README.md CHANGED
@@ -1,90 +1,113 @@
1
1
  # Sequential Thinking MCP Server (Extended Edition) 🧠✨
2
2
 
3
- **MCP Server ที่ช่วยให้ AI "คิดก่อนทำ" อย่างเป็นระบบ พร้อมความสามารถในการค้นหาเว็บ, วิเคราะห์โค้ด และจดจำข้อมูลระยะยาว**
3
+ **MCP Server ที่ยกระดับ AI ให้เป็นวิศวกรซอฟต์แวร์อัจฉริยะ ด้วยระบบ Deepest Thinking และการวิเคราะห์ Codebase เชิงลึก**
4
4
 
5
- โปรเจกต์นี้คือส่วนขยายของ Sequential Thinking ที่เพิ่มเครื่องมือสำคัญเพื่อให้ AI ทำงานเป็น "Autonomous Agent" ได้อย่างสมบูรณ์แบบ ทั้งการวางแผน (Planning), การหาข้อมูล (Research), และการลงมือทำ (Execution)
5
+ โปรเจกต์นี้คือส่วนขยายขั้นสูงของ Sequential Thinking ที่รวมเอาความสามารถในการวางแผนที่เป็นระบบ, การหาข้อมูลทั่วโลก (Web Search), การสร้างแผนผังความสัมพันธ์ของโค้ด (Dependency Graph) และการจัดการหน่วยความจำระยะยาวเข้าด้วยกัน เพื่อให้ AI สามารถทำงานที่ซับซ้อนได้อย่างอิสระและแม่นยำ
6
6
 
7
7
  ---
8
8
 
9
- ## 🔑 Environment Variables (การตั้งค่าตัวแปร)
9
+ ## 🌟 จุดเด่นของเวอร์ชัน Extended
10
+
11
+ 1. **Deepest Thinking Protocol**: บังคับให้ AI วิเคราะห์ปัญหาแบบเป็นลำดับขั้นตอน (Step-by-step) พร้อมการแตกกิ่งความคิด (Branching) และการทบทวนตัวเอง (Reflexion) เพื่อหาทางเลือกที่ดีที่สุด
12
+ 2. **Codebase Intelligence**: ระบบ `ProjectKnowledgeGraph` ที่ใช้ TypeScript Compiler API จริงๆ ในการสแกนความสัมพันธ์ระหว่างไฟล์และ Exported Symbols
13
+ 3. **Deep Coding Workflow**: เครื่องมือใหม่สำหรับการแก้ไขโค้ดที่ต้องผ่านการวิเคราะห์บริบท (Context Document) และการวางแผนที่ผ่านการตรวจสอบเหตุผลแล้วเท่านั้น
14
+ 4. **Optimized Web Extraction**: ระบบอ่านเว็บที่ตัดโฆษณาและส่วนที่ไม่จำเป็นออก (Readability) แปลงเป็น Markdown เพื่อประหยัด Token และให้ข้อมูลที่สะอาดที่สุด
15
+
16
+ ---
10
17
 
11
- นี่คือตัวแปรทั้งหมดที่ระบบรองรับ คุณสามารถเลือกตั้งค่าได้ตามฟีเจอร์ที่ต้องการใช้งาน:
18
+ ## 🔑 Environment Variables (การตั้งค่าตัวแปร)
12
19
 
13
- ### 1. Web Search APIs (เลือกอย่างน้อย 1 อย่างเพื่อใช้ `web_search`)
14
20
  | Variable Name | Description | Required? |
15
21
  |--------------|-------------|-----------|
16
22
  | `BRAVE_API_KEY` | สำหรับค้นหาผ่าน Brave Search | ❌ (Optional) |
17
- | `EXA_API_KEY` | สำหรับค้นหาผ่าน Exa.ai (แนะนำสำหรับงาน Deep Research) | ❌ (Optional) |
23
+ | `EXA_API_KEY` | สำหรับค้นหาผ่าน Exa.ai (แนะนำมากสำหรับงาน Deep Research) | ❌ (Optional) |
18
24
  | `GOOGLE_SEARCH_API_KEY` | Google Custom Search API Key | ❌ (Optional) |
19
25
  | `GOOGLE_SEARCH_CX` | Google Custom Search Engine ID (CX) | ❌ (Optional) |
26
+ | `THOUGHTS_STORAGE_PATH` | ไฟล์เก็บประวัติความคิดเพื่อใช้ต่อเนื่อง | `thoughts_history.json` |
27
+ | `NOTES_STORAGE_PATH` | ไฟล์เก็บความจำระยะยาว (กฎโปรเจกต์, ความชอบ) | `project_notes.json` |
28
+ | `THOUGHT_DELAY_MS` | เวลาหน่วงระหว่างคิด (เพื่อความสมจริงและการจัดการ Rate Limit) | `0` |
29
+
30
+ ---
31
+
32
+ ## 🛠️ รายการเครื่องมือ (Tools Capability)
20
33
 
21
- ### 2. Storage & Memory (การจัดเก็บข้อมูล)
22
- | Variable Name | Description | Default Value |
23
- |--------------|-------------|---------------|
24
- | `THOUGHTS_STORAGE_PATH` | ไฟล์เก็บประวัติการคิด (Thinking History) | `thoughts_history.json` |
25
- | `NOTES_STORAGE_PATH` | ไฟล์เก็บความจำระยะยาว (Long-term Notes) | `project_notes.json` |
34
+ ### 🧠 1. Cognitive & Deepest Thinking
35
+ * **`sequentialthinking`**: (ปรับปรุงใหม่!) บังคับใช้หลักการ **Deepest Thinking** รองรับการทำ Analysis, Reflexion, Evaluation และ Selection ในทุกการแก้ปัญหา
36
+ * **`summarize_history`**: สรุปประวัติความคิดที่ยาวเหยียดเพื่อประหยัดพื้นที่บริบท
37
+ * **`clear_thought_history`**: ล้างสมองเพื่อเริ่มงานชิ้นใหม่
26
38
 
27
- ### 3. System Behavior (พฤติกรรมระบบ)
28
- | Variable Name | Description | Default Value |
29
- |--------------|-------------|---------------|
30
- | `THOUGHT_DELAY_MS` | เวลาหน่วงระหว่างความคิด (ms) เพื่อกัน Rate Limit | `0` |
31
- | `DISABLE_THOUGHT_LOGGING`| ปิดการแสดงผล Log สีสวยงามใน Console (`true`/`false`) | `false` |
39
+ ### 💻 2. Deep Coding & Codebase Context
40
+ * **`deep_code_analyze`**: 🌟 **(ใหม่)** สร้าง Codebase Context Document รวบรวมเนื้อหาไฟล์, Symbols และความสัมพันธ์ (Import/Export) เพื่อให้ AI "เรียนรู้" ก่อนแก้โค้ด
41
+ * **`deep_code_edit`**: 🌟 **(ใหม่)** แก้ไขโค้ดแบบ Surgical Edit โดยต้องระบุ `reasoning` (เหตุผลเชิงลึก) ที่ผ่านการคิดวิเคราะห์มาแล้ว
42
+ * **`build_project_graph`**: สแกนโปรเจกต์เพื่อสร้างแผนผังความสัมพันธ์ทั้งหมด
43
+ * **`get_file_relationships`**: ตรวจสอบว่าไฟล์เป้าหมายกระทบกับส่วนไหนของระบบบ้าง
44
+ * **`search_code`**: ค้นหา Code Pattern ทั้งโปรเจกต์แบบชาญฉลาด
45
+
46
+ ### 🌐 3. External Research
47
+ * **`web_search`**: ค้นหาข้อมูลล่าสุดจากโลกภายนอก (Brave/Exa/Google)
48
+ * **`read_webpage`**: อ่านเนื้อหาเว็บแปลงเป็น Markdown ที่สะอาดและเข้าใจง่าย
49
+ * **`fetch`**: ดึงข้อมูล Raw จาก API ต่างๆ
50
+
51
+ ### 📁 4. System & Persistence
52
+ * **`read_file` / `write_file` / `edit_file`**: จัดการไฟล์ในระบบ
53
+ * **`shell_execute`**: รันคำสั่ง Terminal (เช่น Build, Test, Deploy)
54
+ * **`manage_notes`**: จัดการหน่วยความจำระยะยาวข้ามเซสชัน
32
55
 
33
56
  ---
34
57
 
35
- ## 🚀 Installation & Usage (การติดตั้งและใช้งาน)
58
+ ## 🔄 The "Deep Coding" Workflow (ขั้นตอนการทำงานที่แนะนำ)
36
59
 
37
- สามารถติดตั้งผ่าน npm ได้โดยตรง:
60
+ เพื่อให้ AI ทำงานได้อย่างเทพที่สุด แนะนำให้ใช้ลำดับการทำงานดังนี้:
38
61
 
39
- ```bash
40
- npm install @gotza02/sequential-thinking
41
- ```
62
+ 1. **Map the Codebase**: รัน `build_project_graph` เพื่อให้ AI เข้าใจโครงสร้างโปรเจกต์ทั้งหมด
63
+ 2. **Deep Analysis**: ใช้ `deep_code_analyze` กับไฟล์ที่เกี่ยวข้อง เพื่อสร้างบริบทและความเข้าใจ symbols ที่ใช้งาน
64
+ 3. **Strategic Planning**: ใช้ `sequentialthinking` เพื่อวางแผนแบบ Deepest Thinking (แตกกิ่งความคิด, ทดสอบสมมติฐาน)
65
+ 4. **Precision Edit**: ลงมือแก้ไขด้วย `deep_code_edit` หรือ `edit_file` พร้อมระบุเหตุผลที่วิเคราะห์มาแล้ว
66
+ 5. **Verify**: ใช้ `shell_execute` รันคำสั่ง Test หรือ Lint เพื่อตรวจสอบความถูกต้อง
42
67
 
43
- รองรับทั้ง **Gemini CLI** และ **Claude Desktop**
68
+ ---
44
69
 
45
- ### Option A: ใช้งานผ่าน npx (แนะนำสำหรับผู้ใช้ทั่วไป)
46
- *ไม่ต้องโหลดโค้ด แค่แก้ Config แล้วใช้งานได้เลย*
70
+ ## 🚀 การติดตั้ง (Installation)
47
71
 
48
- #### 1. สำหรับ Gemini CLI
49
- แก้ไขไฟล์ `~/.gemini/settings.json` (หรือ `config.json`):
72
+ คุณสามารถเลือกติดตั้งได้ 2 รูปแบบตามความสะดวกดังนี้:
50
73
 
51
- ```json
52
- {
53
- "mcpServers": {
54
- "smartagent": {
55
- "command": "npx",
56
- "args": ["-y", "@gotza02/sequential-thinking"],
57
- "env": {
58
- "BRAVE_API_KEY": "YOUR_BRAVE_KEY",
59
- "EXA_API_KEY": "YOUR_EXA_KEY",
60
- "GOOGLE_SEARCH_API_KEY": "YOUR_GOOGLE_KEY",
61
- "GOOGLE_SEARCH_CX": "YOUR_GOOGLE_CX",
62
- "THOUGHTS_STORAGE_PATH": "thoughts_history.json",
63
- "NOTES_STORAGE_PATH": "project_notes.json",
64
- "THOUGHT_DELAY_MS": "1000",
65
- "DISABLE_THOUGHT_LOGGING": "false"
66
- }
67
- }
68
- }
69
- }
74
+ ### 1. แบบคำสั่งเดียวจบ (One-Command Setup)
75
+ สำหรับท่านที่ต้องการความรวดเร็วในการติดตั้งและ Build ลงเครื่อง:
76
+ ```bash
77
+ git clone https://github.com/gotza02/sequential-thinking.git && cd sequential-thinking && npm install && npm run build
70
78
  ```
71
79
 
72
- #### 2. สำหรับ Claude Desktop
73
- แก้ไขไฟล์ `claude_desktop_config.json`:
80
+ ### 2. แบบทีละขั้นตอน (Step-by-Step Guide)
81
+ เหมาะสำหรับการปรับแต่งหรือการติดตั้งบนสภาพแวดล้อมที่จำกัด:
82
+
83
+ 1. **Clone Repository**: ดาวน์โหลดโค้ดมายังเครื่องของคุณ
84
+ ```bash
85
+ git clone https://github.com/gotza02/sequential-thinking.git
86
+ cd sequential-thinking
87
+ ```
88
+ 2. **Install Dependencies**: ติดตั้ง Library ที่จำเป็นทั้งหมด
89
+ ```bash
90
+ npm install
91
+ ```
92
+ 3. **Build Project**: ทำการ Compile TypeScript ให้เป็น JavaScript
93
+ ```bash
94
+ npm run build
95
+ ```
96
+ 4. **Configuration**: เปิดไฟล์ตั้งค่า AI Client ของคุณ (เช่น `~/.gemini/settings.json`) แล้วเพิ่มการตั้งค่า MCP Server โดยอ้างอิง Path ไปยังโฟลเดอร์ที่ Build เสร็จแล้ว
97
+
98
+ ---
99
+
100
+ ## ⚙️ การตั้งค่าใน AI Client (Configuration Examples)
74
101
 
75
102
  ```json
76
103
  {
77
104
  "mcpServers": {
78
- "sequential-thinking": {
105
+ "smartagent": {
79
106
  "command": "npx",
80
107
  "args": ["-y", "@gotza02/sequential-thinking"],
81
108
  "env": {
82
- "BRAVE_API_KEY": "YOUR_BRAVE_KEY",
83
- "EXA_API_KEY": "YOUR_EXA_KEY",
84
- "GOOGLE_SEARCH_API_KEY": "YOUR_GOOGLE_KEY",
85
- "GOOGLE_SEARCH_CX": "YOUR_GOOGLE_CX",
86
- "THOUGHTS_STORAGE_PATH": "thoughts_history.json",
87
- "NOTES_STORAGE_PATH": "project_notes.json",
109
+ "BRAVE_API_KEY": "YOUR_KEY",
110
+ "EXA_API_KEY": "YOUR_KEY",
88
111
  "THOUGHT_DELAY_MS": "1000"
89
112
  }
90
113
  }
@@ -94,144 +117,30 @@ npm install @gotza02/sequential-thinking
94
117
 
95
118
  ---
96
119
 
97
- ### Option B: ใช้งานแบบ Local Source (สำหรับนักพัฒนา)
98
- *สำหรับคนที่ต้องการแก้ไขโค้ด หรือรันจากเครื่องตัวเอง*
99
-
100
- 1. **Clone & Build:**
101
- ```bash
102
- git clone <repo_url>
103
- cd sequential-thinking
104
- npm install
105
- npm run build
106
- ```
107
-
108
- 2. **ตั้งค่า Config (ตัวอย่างสำหรับ Gemini CLI):**
109
- *เปลี่ยน Path ให้ตรงกับที่อยู่ไฟล์ในเครื่องคุณ*
110
-
111
- ```json
112
- {
113
- "mcpServers": {
114
- "smartagent": {
115
- "command": "node",
116
- "args": ["/Users/username/projects/sequential-thinking/dist/index.js"],
117
- "env": {
118
- "BRAVE_API_KEY": "YOUR_BRAVE_KEY",
119
- "EXA_API_KEY": "YOUR_EXA_KEY",
120
- "GOOGLE_SEARCH_API_KEY": "YOUR_GOOGLE_KEY",
121
- "GOOGLE_SEARCH_CX": "YOUR_GOOGLE_CX",
122
- "THOUGHTS_STORAGE_PATH": "thoughts_history.json",
123
- "NOTES_STORAGE_PATH": "project_notes.json",
124
- "THOUGHT_DELAY_MS": "1000",
125
- "DISABLE_THOUGHT_LOGGING": "false"
126
- }
127
- }
128
- }
129
- }
130
- ```
131
-
132
- ---
133
-
134
- ## 🛠️ Tools Capability (ความสามารถเครื่องมือ)
135
-
136
- ### 🧠 1. Cognitive Tools (สมองและการคิด)
137
- * **`sequentialthinking`**: เครื่องมือหลัก! ช่วยแตกปัญหาใหญ่เป็นขั้นตอนย่อย (Step-by-step), แตกกิ่งความคิด (Branching), และทบทวนตัวเอง (Reflexion)
138
- * **`summarize_history`**: ย่อสรุปประวัติการคิดที่ยาวเหยียดให้สั้นลง
139
- * **`clear_thought_history`**: ล้างสมอง เริ่มต้นคิดเรื่องใหม่
140
-
141
- ### 🌐 2. Web Capabilities (การเข้าถึงอินเทอร์เน็ต)
142
- * **`web_search`**: ค้นหาข้อมูลล่าสุด (รองรับ Brave, Exa, Google)
143
- * **`read_webpage`**: อ่านเนื้อหาในเว็บแบบ Markdown (ตัดโฆษณาออกให้อัตโนมัติ)
144
- * **`fetch`**: ดึงข้อมูล Raw JSON/HTML จาก API
145
-
146
- ### 🏗️ 3. Codebase Intelligence (ความเข้าใจโค้ด)
147
- * **`build_project_graph`**: สแกนโปรเจกต์เพื่อสร้างแผนผังความสัมพันธ์ (Dependency Graph)
148
- * **`get_file_relationships`**: ดูว่าไฟล์นี้ถูกใครเรียกใช้บ้าง (ป้องกันการแก้แล้วพัง)
149
- * **`search_code`**: ค้นหาโค้ดทั้งโปรเจกต์แบบฉลาด
150
-
151
- ### 📝 4. Long-term Memory (ความจำระยะยาว)
152
- * **`manage_notes`**: บันทึก/อ่าน/แก้ไข ข้อความที่ต้องการให้ AI จำได้ข้าม Session (เช่น กฎของโปรเจกต์, ความชอบของผู้ใช้)
153
-
154
- ### 💻 5. System Operations (จัดการระบบ)
155
- * **`read_file`**: อ่านไฟล์ (ต้องทำก่อนแก้ไฟล์เสมอ)
156
- * **`edit_file`**: แก้ไขไฟล์เฉพาะจุด (Search & Replace) ปลอดภัยกว่าเขียนทับ
157
- * **`write_file`**: สร้างไฟล์ใหม่ หรือเขียนทับทั้งไฟล์
158
- * **`shell_execute`**: รันคำสั่ง Terminal (เช่น `npm test`, `git status`)
159
-
160
- ---
161
-
162
- ## 🤖 Recommended System Instruction (คำสั่งระบบที่แนะนำ)
163
-
164
- เพื่อประสิทธิภาพสูงสุด ให้ Copy ข้อความด้านล่างนี้ไปใส่ใน **System Prompt** ของ AI Agent ที่คุณใช้งาน:
120
+ ## 🤖 Recommended System Instruction
165
121
 
166
122
  ```bash
167
- # 🤖 System Instruction: Enhanced Sequential Engineer
168
-
169
- You are an advanced AI Software Engineer enhanced with the **Sequential Thinking MCP Server**. Your goal is to solve complex problems autonomously, accurately, and safely.
170
-
171
- ## 🧠 PRIME DIRECTIVE: Sequential Thinking
172
-
173
- **Rule #1: NEVER answer complex queries immediately.**
174
- You MUST use the `sequentialthinking` tool to structure your reasoning process.
175
-
176
- 1. **Analyze:** Break the user's request into atomic requirements.
177
- 2. **Plan:** Formulate a step-by-step plan.
178
- 3. **Execute:** Carry out the plan, one step at a time.
179
- 4. **Reflect:** Critique your own work. If a step fails, use `isRevision: true` to correct your course.
123
+ # 🤖 System Instruction: Enhanced Deep Engineer
180
124
 
181
- **Constraints:**
182
- - Do not output code until you have a clear plan.
183
- - If you are unsure, generate a hypothesis and verify it.
125
+ You are a Senior AI Software Engineer equipped with the Sequential Thinking MCP (Extended).
184
126
 
185
- ## 🏗 Codebase Intelligence Protocol
127
+ ## 🧠 CORE MANDATE: Deepest Thinking
128
+ - NEVER solve complex tasks without 'sequentialthinking'.
129
+ - MUST use thoughtType: 'analysis' to map requirements first.
130
+ - MUST use thoughtType: 'reflexion' to critique your own logic.
131
+ - ONLY finish when the solution is verified and satisfactory.
186
132
 
187
- **On Start:**
188
- 1. **Map the Territory:** Run `build_project_graph` immediately to understand the project structure.
189
- 2. **Summarize:** Run `get_project_graph_summary` to identify key files.
133
+ ## 🏗 CODEBASE INTELLIGENCE
134
+ - ALWAYS 'build_project_graph' on start.
135
+ - USE 'deep_code_analyze' before editing any unfamiliar files.
136
+ - ALWAYS check 'get_file_relationships' to avoid breaking dependencies.
190
137
 
191
- **Before Editing:**
192
- 1. **Context Check:** Run `get_file_relationships` to see what depends on the file you are changing.
193
- 2. **Read First:** ALWAYS run `read_file` to get the *current* content. Never rely on memory or assumptions.
194
-
195
- ## 🛠 File Operations Protocol
196
-
197
- - **Small Changes:** Use `edit_file` for surgical replacements. This minimizes the risk of context loss or accidental deletions.
198
- - **New/Large Files:** Use `write_file`.
199
- - **Verification:** After editing, ALWAYS verify the syntax or logic (e.g., run `npm run build` or `npm test` using `shell_execute`).
200
-
201
- ## 🌐 External Knowledge Protocol
202
-
203
- - **Unknown Libs:** If you see a library you don't know, use `web_search` to find its docs.
204
- - **Reading:** Use `read_webpage` to ingest documentation efficiently (markdown format).
205
- - **Errors:** If you hit a cryptic error, search for it.
206
-
207
- ## 📝 Memory & Persistence
208
-
209
- - **Long-Term:** Use `manage_notes` to save architectural decisions, user preferences, or "lessons learned" that should survive this session.
210
- - **Session:** Your thought process is automatically saved. If you crash or restart, review `thoughts_history.json`.
211
-
212
- ## 🔄 The Golden Workflow
213
-
214
- 1. **Discovery:** `build_project_graph` -> `sequentialthinking` (Plan)
215
- 2. **Research:** `web_search` -> `read_webpage`
216
- 3. **Implementation:** `read_file` -> `sequentialthinking` (Refine) -> `edit_file`
217
- 4. **Verification:** `shell_execute` (Test/Build)
218
- 5. **Completion:** Final answer with summary of changes.
138
+ ## 🛠 PRECISION IMPLEMENTATION
139
+ - PREFER 'deep_code_edit' for logical changes.
140
+ - ALWAYS verify changes using 'shell_execute' (npm test, build, etc.).
219
141
  ```
220
142
 
221
143
  ---
222
144
 
223
- ## 📦 Development
224
-
225
- ```bash
226
- # Install dependencies
227
- npm install
228
-
229
- # Build the project
230
- npm run build
231
-
232
- # Run tests
233
- npm test
234
- ```
235
-
236
145
  ## License
237
- MIT
146
+ MIT - พัฒนาโดย @gotza02
package/dist/graph.js CHANGED
@@ -173,6 +173,49 @@ export class ProjectKnowledgeGraph {
173
173
  symbols: node.symbols
174
174
  };
175
175
  }
176
+ getDeepContext(filePath) {
177
+ const absolutePath = path.resolve(this.rootDir, filePath);
178
+ let node = this.nodes.get(absolutePath);
179
+ if (!node) {
180
+ for (const [key, value] of this.nodes.entries()) {
181
+ if (key.endsWith(filePath)) {
182
+ node = value;
183
+ break;
184
+ }
185
+ }
186
+ }
187
+ if (!node)
188
+ return null;
189
+ const context = {
190
+ targetFile: {
191
+ path: path.relative(this.rootDir, node.path),
192
+ symbols: node.symbols
193
+ },
194
+ dependencies: [],
195
+ dependents: []
196
+ };
197
+ // Get symbols and paths for what this file imports
198
+ for (const imp of node.imports) {
199
+ const impNode = this.nodes.get(imp);
200
+ if (impNode) {
201
+ context.dependencies.push({
202
+ path: path.relative(this.rootDir, impNode.path),
203
+ symbols: impNode.symbols
204
+ });
205
+ }
206
+ }
207
+ // Get symbols and paths for what imports this file
208
+ for (const dep of node.importedBy) {
209
+ const depNode = this.nodes.get(dep);
210
+ if (depNode) {
211
+ context.dependents.push({
212
+ path: path.relative(this.rootDir, depNode.path),
213
+ symbols: depNode.symbols
214
+ });
215
+ }
216
+ }
217
+ return context;
218
+ }
176
219
  getSummary() {
177
220
  return {
178
221
  root: this.rootDir,
package/dist/index.js CHANGED
@@ -9,9 +9,10 @@ import { registerWebTools } from './tools/web.js';
9
9
  import { registerFileSystemTools } from './tools/filesystem.js';
10
10
  import { registerGraphTools } from './tools/graph.js';
11
11
  import { registerNoteTools } from './tools/notes.js';
12
+ import { registerCodingTools } from './tools/coding.js';
12
13
  const server = new McpServer({
13
14
  name: "sequential-thinking-server",
14
- version: "2026.1.18",
15
+ version: "2026.2.3",
15
16
  });
16
17
  const thinkingServer = new SequentialThinkingServer(process.env.THOUGHTS_STORAGE_PATH || 'thoughts_history.json', parseInt(process.env.THOUGHT_DELAY_MS || '0', 10));
17
18
  const knowledgeGraph = new ProjectKnowledgeGraph();
@@ -22,6 +23,7 @@ registerWebTools(server);
22
23
  registerFileSystemTools(server);
23
24
  registerGraphTools(server, knowledgeGraph);
24
25
  registerNoteTools(server, notesManager);
26
+ registerCodingTools(server, knowledgeGraph);
25
27
  async function runServer() {
26
28
  const transport = new StdioServerTransport();
27
29
  await server.connect(transport);
@@ -0,0 +1,65 @@
1
+ import { z } from "zod";
2
+ import * as fs from 'fs/promises';
3
+ import * as path from 'path';
4
+ export function registerCodingTools(server, graph) {
5
+ // 14. deep_code_analyze
6
+ server.tool("deep_code_analyze", "Generates a 'Codebase Context Document' for a specific file or task. This tool learns from the codebase structure and symbols to provide deep insights before coding.", {
7
+ filePath: z.string().describe("The file path to analyze as the center of context"),
8
+ taskDescription: z.string().optional().describe("Optional description of what you intend to do")
9
+ }, async ({ filePath, taskDescription }) => {
10
+ try {
11
+ const context = graph.getDeepContext(filePath);
12
+ if (!context) {
13
+ return { content: [{ type: "text", text: `Error: File '${filePath}' not found in graph. Run 'build_project_graph' first.` }], isError: true };
14
+ }
15
+ const fileContent = await fs.readFile(path.resolve(filePath), 'utf-8');
16
+ let doc = `--- CODEBASE CONTEXT DOCUMENT: ${filePath} ---\n\n`;
17
+ if (taskDescription) {
18
+ doc += `TASK: ${taskDescription}\n\n`;
19
+ }
20
+ doc += `FILE CONTENT:\n\`\`\`\n${fileContent}\n\`\`\`\n\n`;
21
+ doc += `EXPORTED SYMBOLS:\n${context.targetFile.symbols.join(', ')}\n\n`;
22
+ doc += `DEPENDENCIES (Used by this file):\n`;
23
+ context.dependencies.forEach(d => {
24
+ doc += `- ${d.path} (Symbols: ${d.symbols.join(', ')})\n`;
25
+ });
26
+ doc += `\nDEPENDENTS (Files that use this file):\n`;
27
+ context.dependents.forEach(d => {
28
+ doc += `- ${d.path} (Symbols: ${d.symbols.join(', ')})\n`;
29
+ });
30
+ doc += `\n--- END OF CONTEXT ---`;
31
+ return {
32
+ content: [{ type: "text", text: doc }]
33
+ };
34
+ }
35
+ catch (error) {
36
+ return { content: [{ type: "text", text: `Analysis Error: ${error instanceof Error ? error.message : String(error)}` }], isError: true };
37
+ }
38
+ });
39
+ // 15. deep_code_edit
40
+ server.tool("deep_code_edit", "Apply a surgical code edit based on a 'Deepest Thinking' plan. Use this tool AFTER analyzing the codebase and formulating a thought sequence.", {
41
+ path: z.string().describe("Path to the file to edit"),
42
+ oldText: z.string().describe("The exact text to replace"),
43
+ newText: z.string().describe("The new code to insert"),
44
+ reasoning: z.string().describe("The 'Deepest Thinking' reasoning behind this change")
45
+ }, async ({ path: filePath, oldText, newText, reasoning }) => {
46
+ try {
47
+ const absolutePath = path.resolve(filePath);
48
+ const content = await fs.readFile(absolutePath, 'utf-8');
49
+ if (!content.includes(oldText)) {
50
+ return { content: [{ type: "text", text: "Error: Target text not found. Ensure exact match including whitespace." }], isError: true };
51
+ }
52
+ const newContent = content.replace(oldText, newText);
53
+ await fs.writeFile(absolutePath, newContent, 'utf-8');
54
+ return {
55
+ content: [{
56
+ type: "text",
57
+ text: `Successfully applied edit to ${filePath}.\nReasoning verified: ${reasoning}`
58
+ }]
59
+ };
60
+ }
61
+ catch (error) {
62
+ return { content: [{ type: "text", text: `Edit Error: ${error instanceof Error ? error.message : String(error)}` }], isError: true };
63
+ }
64
+ });
65
+ }
@@ -1,9 +1,16 @@
1
1
  import { z } from "zod";
2
2
  export function registerThinkingTools(server, thinkingServer) {
3
3
  // --- Sequential Thinking Tool ---
4
- server.tool("sequentialthinking", `A detailed tool for dynamic and reflective problem-solving through thoughts.
5
- This tool helps analyze problems through a flexible thinking process that can adapt and evolve.
6
- Each thought can build on, question, or revise previous insights as understanding deepens.
4
+ server.tool("sequentialthinking", `A specialized tool for Deepest Thinking, providing dynamic and reflective problem-solving.
5
+ This tool mandates a rigorous analysis process that adapts and evolves as understanding deepens.
6
+ Use this tool ALWAYS for complex queries to ensure the most thorough and accurate solution.
7
+
8
+ Deepest Thinking Requirements:
9
+ - Mandatory Analysis: Break down problems into atomic requirements before generating solutions.
10
+ - Mandatory Reflexion: Critique your own thoughts regularly to identify biases or errors.
11
+ - Mandatory Branching: Explore alternative hypotheses (Conservative/Balanced/Aggressive) for critical decisions.
12
+ - Dynamic Depth: Adjust total_thoughts as new complexities are discovered.
13
+ - Correctness focus: Repeat the process until a verified, satisfactory answer is reached.
7
14
 
8
15
  When to use this tool:
9
16
  - Breaking down complex problems into steps
@@ -15,55 +22,30 @@ When to use this tool:
15
22
  - Situations where irrelevant information needs to be filtered out
16
23
 
17
24
  Key features:
18
- - You can adjust total_thoughts up or down as you progress
19
- - You can question or revise previous thoughts
20
- - You can add more thoughts even after reaching what seemed like the end
21
- - You can express uncertainty and explore alternative approaches
22
- - Not every thought needs to build linearly - you can branch or backtrack
23
- - Iterative Reasoning: Think step-by-step in a structured manner
24
- - Tree of Thoughts: Generate and evaluate multiple options (Conservative/Balanced/Aggressive)
25
- - Self-Critique: Check for risks, biases, and errors in thinking
26
- - Branch Merging: Combine insights from multiple divergent paths
27
- - Hypothesis Testing: Formulate and verify hypotheses
28
- - Generates a solution hypothesis
29
- - Verifies the hypothesis based on the Chain of Thought steps
30
- - Repeats the process until satisfied
31
- - Provides a correct answer
25
+ - Tree of Thoughts: Generate and evaluate multiple options.
26
+ - Self-Critique: Check for risks, biases, and errors in thinking.
27
+ - Hypothesis Testing: Formulate and verify hypotheses based on Chain of Thought.
28
+ - Branch Merging: Combine insights from multiple divergent paths.
32
29
 
33
30
  Parameters explained:
34
- - thought: Your current thinking step, which can include:
35
- * Regular analytical steps
36
- * Revisions of previous thoughts
37
- * Questions about previous decisions
38
- * Realizations about needing more analysis
39
- * Changes in approach
40
- * Hypothesis generation
41
- * Hypothesis verification
42
- - nextThoughtNeeded: True if you need more thinking, even if at what seemed like the end
43
- - thoughtNumber: Current number in sequence (can go beyond initial total if needed)
44
- - totalThoughts: Current estimate of thoughts needed (can be adjusted up/down)
45
- - isRevision: A boolean indicating if this thought revises previous thinking
46
- - revisesThought: If is_revision is true, which thought number is being reconsidered
47
- - branchFromThought: If branching, which thought number is the branching point
48
- - branchId: Identifier for the current branch (if any)
49
- - needsMoreThoughts: If reaching end but realizing more thoughts needed
50
- - thoughtType: The type of thought (analysis, generation, evaluation, reflexion, selection)
51
- - score: Score for evaluation (1-10)
52
- - options: List of options generated
53
- - selectedOption: The option selected
31
+ - thought: Your current thinking step (analysis, revision, question, hypothesis).
32
+ - nextThoughtNeeded: True if you need more thinking, even if at what seemed like the end.
33
+ - thoughtNumber: Current number in sequence.
34
+ - totalThoughts: Current estimate of thoughts needed (can be adjusted).
35
+ - isRevision: True if this thought revises previous thinking.
36
+ - revisesThought: Which thought number is being reconsidered.
37
+ - branchFromThought: The branching point thought number.
38
+ - branchId: Identifier for the current branch.
39
+ - thoughtType: The type of thought (analysis, generation, evaluation, reflexion, selection).
40
+ - score: Score for evaluation (1-10).
41
+ - options: List of options generated.
42
+ - selectedOption: The option selected.
54
43
 
55
- You should:
56
- 1. Start with an initial estimate of needed thoughts, but be ready to adjust
57
- 2. Feel free to question or revise previous thoughts
58
- 3. Don't hesitate to add more thoughts if needed, even at the "end"
59
- 4. Express uncertainty when present
60
- 5. Mark thoughts that revise previous thinking or branch into new paths
61
- 6. Ignore information that is irrelevant to the current step
62
- 7. Generate a solution hypothesis when appropriate
63
- 8. Verify the hypothesis based on the Chain of Thought steps
64
- 9. Repeat the process until satisfied with the solution
65
- 10. Provide a single, ideally correct answer as the final output
66
- 11. Only set nextThoughtNeeded to false when truly done and a satisfactory answer is reached`, {
44
+ You MUST:
45
+ 1. Use thoughtType: 'analysis' for the first steps to map requirements.
46
+ 2. Use thoughtType: 'reflexion' frequently to validate logic.
47
+ 3. Use thoughtType: 'evaluation' and 'selection' when choosing between branches.
48
+ 4. Only set nextThoughtNeeded to false when the solution is definitive and fully verified.`, {
67
49
  thought: z.string().describe("Your current thinking step"),
68
50
  nextThoughtNeeded: z.boolean().describe("Whether another thought step is needed"),
69
51
  thoughtNumber: z.number().int().min(1).describe("Current thought number (numeric value, e.g., 1, 2, 3)"),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gotza02/sequential-thinking",
3
- "version": "2026.2.2",
3
+ "version": "2026.2.3",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },